jnroche Posted November 15, 2006 Share Posted November 15, 2006 my form is<form> <select name="slctreasons"> <option id="<?" value="<?php echo $reasonID; ?>" ><?php echo $myrows['reason']; ?></option> </form>the entire list of reasons is captured in that option tag, in a loop ofcourse, to list down all the reason inside the database table.my problem is i want to get both reasonID and reason text itself in javascript. my initial javascript code is:document.getElementById('slctreasons').value this line only gets whatever the value in the selected option is, which is the reasonID! I also wanted the text itself....i dont know much about javascriptany help thanks Link to comment Share on other sites More sharing options...
jesh Posted November 15, 2006 Share Posted November 15, 2006 It's part of the HTML DOM. var select = document.getElementById("slctreasons");var option = select.options[select.selectedIndex];var text = option.text;var value = option.value; Link to comment Share on other sites More sharing options...
jnroche Posted November 16, 2006 Author Share Posted November 16, 2006 It's part of the HTML DOM.var select = document.getElementById("slctreasons");var option = select.options[select.selectedIndex];var text = option.text;var value = option.value; nice, thanks Link to comment Share on other sites More sharing options...
jnroche Posted November 17, 2006 Author Share Posted November 17, 2006 It's part of the HTML DOM.var select = document.getElementById("slctreasons");var option = select.options[select.selectedIndex];var text = option.text;var value = option.value; nice thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now