Long time no new entry. 🙂 Internship is keeping me very busy. In this blog entry I’ll show you how to select a drop down option by specifying its index number.
The JavaScript code:
1 |
document.getElementById("selectionDD").selectedIndex = 0; |
The HTML code:
1 2 3 4 5 |
<select id="selectionDD" name="selectionDD">      <option value="one">One</option>      <option value="two">Two</option>      <option value="three">Three</option> </select> |
Refer to the JavaScript code. The selectionDD
is the id of the <select>
tag. The value 0 represents the index number of the option that we want to be selected, and will select the first option in the selection. Note that the index numbers start with 0, not 1.
hi catzie, wow all about web design na pala itong blog. thats nice.
Hello Scart. I followed you too. Oo nga eh, naging all about web design and coding na itong blog. 😀
BTW, i followed u on twitter XD