Monday, April 21, 2008

Javascript: Get a Value from a Drop Down Menu

To get the value:
document.getElementById( 'dropdownmenu_id' ).options[ document.getElementById('dropdownmenu_id').selectedIndex ].value


To get the Option Name:
document.getElementById('dropdownmenu_id').options[ document.getElementById('dropdownmenu_id').selectedIndex ].text


if you use prototype.js framework then you can replace the
references to 'document.getElementById' with a $

No comments: