Reputation: 18022
I have a search form
<form id="search" method="GET">
<input type="text" name="q" id="q" />
<input type="submit" value="search" name="submit" id="submit" />
</form>
and when I submit it it adds ?q=&submit=submit
to the URL is there a way that I can keep it from appending submit=submit
but still pass the q=
?
Upvotes: 2
Views: 5186
Reputation: 29121
You could just use an anchor instead of a form input:
<script type="text/javascript">
function submitForm() {
document.getElementById('search').submit();
}
</script>
<form id="search" method="GET">
<input type="text" name="q" id="q" />
<a href="javascript: submitForm();">Submit</a>
</form>
Or, you could add an onsubmit to the form, and use javascript to disable the input field, which should keep it from showing in the URL.
Upvotes: 0
Reputation: 107
Change the button type from:
type="submit"
To:
type="button"
i.e.
<button type="button">Login</button>
Upvotes: 0
Reputation:
Would using post instead of get be out of the question because that wouldn't show anything in the url.
Upvotes: 0
Reputation: 11056
If you remove the name
attribute from your <input type="submit" />
then that should get rid of submit=submit
from the querystring (a quick test in Firefox / Firebug confirmed this). For example:
<input type="submit" value="search" />
Upvotes: 8
Reputation: 61737
Try using a button:
<button type="submit">Submit Form</button>
Upvotes: 0