acidglitter Posted April 6, 2008 Share Posted April 6, 2008 I have a simple form like.. <select id="select"> <option>Option1</option> <option>Option2</option> </select> If I check off a box or something, what javascript code would change the select form so the 2nd option is selected? Link to comment https://forums.phpfreaks.com/topic/99846-javascript-and-html-forms/ Share on other sites More sharing options...
michaellunsford Posted April 7, 2008 Share Posted April 7, 2008 This should work ;-) <form> <select id="select" name="select"> <option value="Option1">Option1</option> <option value="Option2">Option2</option> </select><input type="checkbox" onchange="document.forms[0].select.value='Option2';" /> </form> Link to comment https://forums.phpfreaks.com/topic/99846-javascript-and-html-forms/#findComment-510935 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.