How to prevent a form with GET method from sending the value of the submit button?

I have a simple form:

<form action="/search" method="get">
    <input type="text" name="q" value="">
    <input type="submit" name="search" value="search">

When submitting the url becomes `/search?q=Loremipsum&search=search

I really don't want that last bit, this seems pretty common problem and think it could be solved without js, but I realized that even has this problem when you click on the search button. (maybe they don't care much about ugly urls?)


Is there a way to prevent the value of the submit button to be excluded without javascript?

I see in Stack overflow the search is ?q= but they don't have a submit button.


You can omit name attribute in the final input like this:

<form action="/search" method="get">
    <input type="text" name="q" value="">
    <input type="submit" value="search">

Should do the trick. Keeping value attribute allows you to manipulate what text is displayed on the button.

For the record, you can also omit the submit button if you like, and the form will submit when you press return after typing your search term. (This is how the Stack Overflow search box works).

Need Your Help

Set screen-title from shellscript

bash title gnu-screen xterm

Is it possible to set the Screen Title using a shell script?

C++ Boost ASIO simple periodic timer?

c++ linux boost boost-asio

I want a very simple periodic timer to call my code every 50ms. I could make a thread that sleeps for 50ms all the time (but that's a pain)... I could start looking into Linux API's for making time...