Showing posts with label html drop down. Show all posts
Showing posts with label html drop down. Show all posts

Sunday, November 15, 2009

Drop down methods

java script methods for drop down.

selectedIndex - to get the selected index value
options[].value - to get the value of the selected item
options[].text - to get the option for the selected item

ex:


var list_box = document.getElementById('id_of_dropdown_box');
list_box.selectedIndex; --> returns the value of selected index(drop down index starts from 0) '1' check

options[0].value --> value of the zero th element '1' check

options[0].text --> text of the zero th element 'Ruby' check