Enter as default instead of button click in <FORM>
Posted: Fri Dec 26, 2003 1:06 pm
I have a html file :
Enter some name say John.
If we hit the enter key, it goes here :
http://localhost/Query.php?txtName=john
If we click then search button, it goes here :
http://localhost/Query.php?txtName=john ... rch=Search
In my php code of Query.php I have this
Obviously this won't work if we hit the enter key. Only if the button is clicked then it'll work. So how do I resolve this ?
I already tried a javascript code for onkeypress in the txtName(gave id for that) and did document.open() etc etc but it didn't work either.
I do not want to do
because the actual page has multiple forms with same action link.
Thanks
Code: Select all
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM ACTION="Query.php">
Name :
<INPUT name=txtName>
<INPUT type="Submit" value="Search" name=SubmitBasicSearch>
</FORM>
</BODY>
</HTML>If we hit the enter key, it goes here :
http://localhost/Query.php?txtName=john
If we click then search button, it goes here :
http://localhost/Query.php?txtName=john ... rch=Search
In my php code of Query.php I have this
Code: Select all
<?php
if (isset($SubmitBasicSearch)) SearchName($txtName);
?>I already tried a javascript code for onkeypress in the txtName(gave id for that) and did document.open() etc etc but it didn't work either.
I do not want to do
Code: Select all
<?php
if (isset($txtName)) SearchName($txtName);
?>Thanks