Jump to content

[SOLVED] Form submit in textbox when enter key hit


forcom

Recommended Posts



<table cellpadding="0" cellspacing="0" width="954" border="0" height="258" bgcolor="FFFFFF">
<tr><td colspan="2">
<center><br>
<form method="post">
<table cellpadding="0" cellspacing="0" width="380" height="30">
        <tr>
                         <td width="297" valign="middle">
                <input type="text" name="gosearch" size="40">
                </td>
                <td width="108">
                <input type="submit" value="Go Search" name="search">
                </td>
                </tr></form>
</table>

Try this, you had the form ending before the table.  I also converted your width and valign to proper css.

 

<form method="post" enctype="multipart/form-data">
<table cellpadding="0" cellspacing="0" width="380" height="30">
        <tr>
			<td style="width: 297px; vertical-align: middle;"><input type="text" name="gosearch" size="40" /></td>
			<td style="width: 108px; vertical-align: middle;"><input type="submit" value="Go Search" name="search" /></td>
		</tr>
</table>
</form>

I tried and still having the same problem. When I type in a word in the text area and click on go search button everything works but if I just type in the word and press the enter key on the keyboard I don`t get any results.

 

How can I code this so when user hits the enter key on the keyboard.

 

if(isset($_POST['search']) ){

//Submit button hit or Enter button hit

}


The script below works on enter, I just tested it.  If this doesn't work for you then please post your code so we can see the issue.

 

<?php
if(isset($_POST['gosearch'])){
  echo $_POST['gosearch'];
}
?>
<html>
<head>
</head>
<body>
<form method="post" enctype="multipart/form-data">
   <table cellpadding="0" cellspacing="0" width="380" height="30">
           <tr>
            <td style="width: 297px; vertical-align: middle;"><input type="text" name="gosearch" size="40" /></td>
            <td style="width: 108px; vertical-align: middle;"><input type="submit" value="Go Search" name="search" /></td>
         </tr>
   </table>
</form>
</body>
</html>

Thanks for the information. I got it to work :D

I change code around that you submited. I remove input submit name and change text area name to keywords. Thanks for the help

 

if(isset($_POST['keywords'])){

//it works

}

 

<form method="post" enctype="multipart/form-data">
<table cellpadding="0" cellspacing="0" width="380" height="30">
        <tr>
			<td style="width: 297px; vertical-align: middle;"><input type="text" name="keywords" size="40"/></td>
			<td style="width: 108px; vertical-align: middle;"><input type="submit" value="Go Search" /></td>
		</tr>
</table>
</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.