Minimum 2 txt fields required in a form to hit Enter Key
Posted: Sun Jan 18, 2004 6:06 am
This is something that has taken me quite a while to figure this out.
Code 1 :
Code 2:
Code 1 works only if you click the Submit button
Code 2 works if you click the Submit button or hit the enter key in any one of the text fields (txtName or dummy).
So a minimum of 2 text input fileds are required to get it work on hitting the enter key in the fields.
If there is just 1 field we have to click the Submit button.
On hitting the enter key in the txtName field :
Code 1 returns : http://localhost/Query.php?txtName=something
Code 2 returns : http://localhost/Query.php?txtName=some ... rch=Search
In my PHP code I have :
So how do I resolve this ? I need the code to work even if someone hits the enter key in a 1 text field only form.
Thanks
Code 1 :
Code: Select all
<FORM ACTION="Query.php">
Name :
<INPUT name=txtName>
<INPUT type="Submit" value="Search" name="Search">
</FORM>Code 2:
Code: Select all
<FORM ACTION="Query.php">
Name :
<INPUT name=txtName>
<INPUT name=dummy>
<INPUT type="Submit" value="Search" name="Search">
</FORM>Code 1 works only if you click the Submit button
Code 2 works if you click the Submit button or hit the enter key in any one of the text fields (txtName or dummy).
So a minimum of 2 text input fileds are required to get it work on hitting the enter key in the fields.
If there is just 1 field we have to click the Submit button.
On hitting the enter key in the txtName field :
Code 1 returns : http://localhost/Query.php?txtName=something
Code 2 returns : http://localhost/Query.php?txtName=some ... rch=Search
In my PHP code I have :
Code: Select all
if (isset(Search))Thanks