JKirchartz
JKirchartz

Reputation: 18022

Can you keep submit=submit from showing in the URL after submitting a form?

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

Answers (7)

Dave
Dave

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

Christos Maris
Christos Maris

Reputation: 107

Change the button type from:

type="submit"

To:

type="button"

i.e.

<button type="button">Login</button>

Upvotes: 0

someguy
someguy

Reputation: 1

Change the button's name to name=''

Upvotes: 0

user684970
user684970

Reputation:

Would using post instead of get be out of the question because that wouldn't show anything in the url.

Upvotes: 0

Ian Oxley
Ian Oxley

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

Tom Gullen
Tom Gullen

Reputation: 61737

Try using a button:

<button type="submit">Submit Form</button>

Upvotes: 0

bradley.ayers
bradley.ayers

Reputation: 38382

No. You would need to remove the input.

Upvotes: -2

Related Questions