Using a HTML select element to add get parameters to URL
I'm on a page like /gallery.php?place=300&name=place1
, and I want it so that when I submit this form it goes to /gallery.php?place=300&name=place1&tag=X
, where X is the number of the tag selected.
What's wrong here?
<form action="/gallery.php?place=300&name=place1" method="get">
<s开发者_如何学JAVAelect name="tag">
<option value=1>Aerial</option>
<option value=2>Autumn</option>
<option value=4>Boats</option>
<option value=6>Buildings</option>
<option value=7>Canals</option>
</select>
<input type="submit" value="Filter"/>
</form>
Use hidden
inputs instead of trying to use the query string twice:
<form action="/gallery.php" method="get">
<select name="tag">
<option value=1>Aerial</option>
<option value=2>Autumn</option>
<option value=4>Boats</option>
<option value=6>Buildings</option>
<option value=7>Canals</option>
</select>
<input type="hidden" name="place" value="300" />
<input type="hidden" name="name" value="place1" />
<input type="submit" value="Filter" />
</form>
Using a form with method get
was overwriting the query string in your form action
.
This extra parameters seem to work for me locally when using "post" instead of "get." Is that it?
精彩评论