ellcon
07-03-2002, 05:33 PM
I need a drop down box selection to act as a submit button, to post data to another webpage when it is selected- how will this work?
Thanks
-Ian
Thanks
-Ian
|
||||
using a dropdown selection as a submit buttonellcon 07-03-2002, 05:33 PM I need a drop down box selection to act as a submit button, to post data to another webpage when it is selected- how will this work? Thanks -Ian brothercake 07-03-2002, 06:30 PM <select onchange="document.forms.formname.submit()"> should do it adios 07-03-2002, 06:48 PM I'm guessing you don't want the entire SELECT to submit - just one particular option; so... <form onsubmit="alert('OK');return false"> <select onchange="if(this.selectedIndex==4)this.form.submit()"> <option selected="selected">choose</option> <option>option 1</option> <option>option 2</option> <option>option 3</option> <option>submit form</option> </select> </form> Do it this way if you're not using a regular submit button anywhere. If you are, try this: <form onsubmit="alert('OK');return false"> <select onchange="if(this.selectedIndex==4)sub.click()"> <option>choose</option> <option>option 1</option> <option>option 2</option> <option>option 3</option> <option>submit form</option> </select> <input name="sub" type="submit"> </form> Notice the alert() - calling Form.submit() directly doesn't activate the onsubmit event handler, while simulating a submit button click does - important if you're using the handler for validation routines. Your choice. Set the .selectedIndex==number to the submitting option number (Javascript counts from zero). |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum