একটি ড্রপ-ডাউন তালিকায় নির্বাচিত বিকল্পের সূচী দেখাতে, নির্বাচিত সূচক ব্যবহার করুন জাভাস্ক্রিপ্টে সম্পত্তি।
উদাহরণ
আপনি নির্বাচিত বিকল্পের সূচী প্রদর্শন করতে নিম্নলিখিত কোড চালানোর চেষ্টা করতে পারেন −
<!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>