Reputation: 1029
I have a select dropdown
<select form="orderby" name="order" >
<option value="name">Name</option>
<option value="rating">Rating</option>
<option value="likes">Popularity</option>
<option value="time">Time</option>
<option value="cost">Cost</option>
</select>
<select form="orderby" name="sort" >
<option value="ASC">Ascending</option>
<option value="DESC">Descending</option>
</select>
<form style="display:inline-block" id="orderby" action="frapnel2.php">
<input type="hidden" name="city" value="<?php echo $city;?>" />
<input type="submit" value="Go"/>
</form>
What happens is after selecting the option and hitting go I call my page with the new values and what I have to but I want to get rid of pressing go every time. How do I do that?
Upvotes: 0
Views: 3093
Reputation: 4752
The simplest solution is to add an onchange
attribute to the <select>
element that submits the form. Eg:
<select form="orderby" name="order" onchange="form.submit()">
Note:
There should always be a submit button (on a public web page), even if you don't think you need one. You cannot know with certainty that the users browser will execute your scripts, or execute them correctly. There are few things that are more annoying than web forms that cannot be submitted.
The form=...
attribute is new in HTML5. Some say it is not supported by IE. Your best bet is probably to put the form elements inside a <form>
.
Upvotes: 1