PDA

View Full Version : Changing form action with a dropdown



kkroo
04-10-2006, 07:43 PM
I have a form, and i would like the user to be able to submit it to different servers by selecting a option from a <select> menu and it would change the value of the action page in <form> without reloading the page

so i think it would be something like this

<form action=javascript:action; >

Thanks in advance!

ddadmin
04-10-2006, 09:40 PM
Something like the below select menu should do it:


<select size="1" onChange="this.form.action=this.options[this.selectedIndex].value;">
<option value="default.php">Select action</option>
<option value="bob.php">Bob</option>
<option value="joe.php">Joe</option>
</select>

kkroo
04-11-2006, 10:00 AM
Thank you soooo much, that is exactly what i want! Thanks!!!!!!

jwpupecki
10-07-2011, 05:40 PM
I am trying to get the action to submit to a different web page based upon which item they select in the drop down list. Here is what I have:

<form id="ClassSearch" name="ClassSearch" method="get" action=javascript:action>
<p>
<label for="GroupId"><strong>Center:</strong></label>
<select name="GroupId" id="GroupId" onChange="this.form.action=this.options[this.selectedIndex].value;">
<option value="http://www.nhconn.com/LOCALWEB/catalog/CourseCatalog.aspx">Bloomfield, CT</option><option value="http://www.nhconn.com/LOCALWEB/catalog/CourseCatalog.aspx">Hartford, CT</option>
<option value="http://www.nhboston.com/LOCALWEB/catalog/CourseCatalog.aspx">Boston, MA</option>
<option value="http://www.nhnhboston.com/LOCALWEB/catalog/CourseCatalog.aspx">Waltham, MA</option>
<option value="http://www.nhnj.com/LOCALWEB/catalog/CourseCatalog.aspx">Iselin, NJ</option>
<option value="http://www.nhnj.com/LOCALWEB/catalog/CourseCatalog.aspx">Parsippany, NJ</option>
<option value="http://www.nhnj.com/LOCALWEB/catalog/CourseCatalog.aspx">Princeton, NJ</option>
<option value="http://www.nhphilly.com/LOCALWEB/catalog/CourseCatalog.aspx">Philadelphia, PA</option>
<option value="http://www.nhphilly.com/LOCALWEB/catalog/CourseCatalog.aspx">King of Prussia, PA</option> <option value="http://www.nhnashua.com/LOCALWEB/catalog/CourseCatalog.aspx">Nashua, NH</option>
<option value="http://www.nhny.com/LOCALWEB/catalog/CourseCatalog.aspx">New York, NY</option> <option value="http://www.nhli.com/LOCALWEB/catalog/CourseCatalog.aspx">Long Island, NY</option> <option value="http://www.nhrhodeisland.com/LOCALWEB/catalog/CourseCatalog.aspx">Providence, RI</option> <option value="http://www.nhseattle.com/LOCALWEB/catalog/CourseCatalog.aspx">Seattle, WA</option> </select>
</p>
<p>
<label for="keyword2"><strong>Class:</strong></label>
<input type="text" name="keyword" id="keyword2" />
<input name="searchmode" type="hidden" id="searchmode" value="1" />
</p>
<p>
<input type="submit" name="button" id="button" value="Submit" />
</p>
</form>

mburt
10-07-2011, 05:54 PM
It works fine for me! I'm not sure what the issue is. When you select an item, and then press submit, it seems to work fine.