ড্রপডাউন লিস্টে সিলেক্টেড অপশনের ইনডেক্স দেখাতে জাভাস্ক্রিপ্টে selectedIndex প্রোপার্টি ব্যবহার করুন।
উদাহরণ
সিলেক্টেড অপশনের ইনডেক্স প্রদর্শন করতে নিচের কোডটি চালান −
<!DOCTYPE html> <html> <body> <form id="myForm"> <select id="selectNow"> <option>One</option> <option>Two</option> <option>Three</option> </select> <input type="button" onclick="display()" value="Click"> </form> <p>Select and click the button to get the index of the selected option.</p> <script> function display() { var index = document.getElementById("selectNow").selectedIndex; document.write(index); } </script> </body> </html>