Forum Moderators: open

Message Too Old, No Replies

Form submit and search query

wrong behaviour at pressing Enter

         

mcibor

9:41 pm on May 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have such simple code:
<form name="enter" action="#" method="POST">
<table><tr><td>a1 <input type="text" name="a"></td></tr>
<tr><td><input type="submit" name="sa" value="a"></td></tr></table>
<br><table><tr><td>b1 <input type="text" name="b"></td><td><input type="submit" name="sb" value="b"></td></tr></table>
</form>

Where "a" is a form for getting some values, and "b" is a input to put search query. My problem is such, that when user writes something in "b" (search string) and presses Enter, the form is submitted with "sa" set, not as I would like "sb".
What should I do to correct this problem? Changing the position of "a" and "b" is not possible.
Summarizing, if a user presses Enter in "a" field I would like to submit "sa", if a user presses Enter in "b" field then I would like to submit "sb".
Thanks for any answer
Michal Cibor

tedster

5:40 am on May 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not clear why you have two submit inputs - you can send data from many text inputs with one submit. Is there ever a case where you want someone to be able to send "a"?

mcibor

2:44 pm on May 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first inputs and submit are for creating a new user, and the second input and submit are for doing search. Therefore I cannot and don't want to combine them. However if you know of some way to send search string without submiting I'm open to suggestions.

The real code is: input user; pass; pass again; submit New user.
input search; submit Do search

I use mozilla.
I would welcome any answer
Michal Cibor

tedster

3:52 pm on May 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about two forms, then? Is there some reason they must be combined into one form?

mcibor

8:19 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Tedster!

After putting them into two separate forms it works fine!
Best regards
Michal Cibor