Forum Moderators: open

Message Too Old, No Replies

Multiple Form Selection

         

Scott Botkins

5:26 am on Mar 19, 2006 (gmt 0)

10+ Year Member



Hey Everyone,

I'm stuck on something I need done badly.

For my cms, it requires this for the search:

<form action="searchnews.pl?dosearch" method="POST" name="searchnews">
Search Query: <input type="text" size="35" name="searchquery"><br>
<input type="submit" value="Search">
<input type="submit" value="Search">
<input type="reset">
</form>

I need to use 4 of them for example music/searchnews.pl?dosearch, games/searchnews.pl?dosearch, movies/searchnews.pl?dosearch, wrestling/searchnews.pl?dosearch

I already have my form made:

<form action="games/searchnews.pl?dosearch" method="POST" name="searchnews"><input name="searchquery" type="text" style="font-size: 8pt; font-family: Tahoma" size="61" /><option>Select A Category<option>- Video Games<option>- Movies<option>- Music
<option>- Wrestling</select><input type="submit" style="font-size: 11px; font-family: Tahoma" value="Search!">

I have games set to default, how can I make so when they select an option it will show the correct form action?

Thanks,
Scott

DrDoc

5:30 am on Mar 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assuming that the value for all the options matches the subdirectory (i.e. games, movies), add this to your select:

onchange="this.form.action = this.options[this.selectedIndex].value + '/searchnews.pl?dosearch'"

You do know, by the way, that if someone disables JavaScript you're out of luck, right?

Scott Botkins

5:35 am on Mar 19, 2006 (gmt 0)

10+ Year Member



thank you very much, i got it working.

yea i'm ware of the javascript issue, thanks though.