Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submit form with enter key

Status
Not open for further replies.

rs51

Technical User
Oct 13, 2001
163
PT
hi
i've this form:
<form action=&quot;<?=$_SERVER['PHP_SELF']?>&quot; method=&quot;POST&quot; onkeypress=&quot;if(window.event.keyCode==13){this.submit()};&quot;>
<p>Base de dados:
<select name=&quot;db&quot;>
<?php
$dbs = mysql_list_dbs();
for ($i=0;$i<mysql_num_rows($dbs);$i++) {
$dbname = mysql_db_name($dbs,$i);
if ($dbname == $db)
echo(&quot;<option selected>$dbname</option>\n&quot; );
else
echo(&quot;<option>$dbname</option>\n&quot; );
}
?>
</select>
</p>
<p>SQL:<br />
<textarea cols=&quot;60&quot; rows=&quot;5&quot; name=&quot;query&quot;><?=htmlspecialchars($query)?></textarea>
</p>
<p><input type=&quot;submit&quot; name=&quot;submitquery&quot; value=&quot;Ver&quot; /></p>
</form>
and want to submit by either clikin on button or by pressing the enter key;
the way it is only reloads the web page and resets the select option...
How can i achieve it?
Thanks
 
this would disable carriage returns in the <textarea>...why use a textarea?

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
yeah ike jemminger said if u press enter in a textarea it will go to the next line, but if it is a textfield it will submit the form...

Known is handfull, Unknown is worldfull
 
the textarea is suposed to be where i write sql code to query databases...
 
then like i explained the enter key wont work (atleast when the foucus is in the textarea)...

Known is handfull, Unknown is worldfull
 

jemminger:
you said &quot;why use a textarea?&quot;
Using textarea i dont have to rewrite the same sql every time i need to query my database (that's what's for this form)
i click enter but the text stays inside the textarea, which does not happen with a textbox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top