Enter key press triggers button element

I made a PHP page where a HTML element either displays or hides a table, and then that table would have a search bar among other not-so-important things.
I managed both the bar working (not as a search, but to change text in the table instead, just for testing) and the hide/show button working. But not while both input elements active.

To avoid the following to achieve the solution:

[ul][li]-Javascript to disable enter key press on the button.
-Use a link as a submit button (javascript too).
-Use CSS’ to trigger a PHP fuction (similar to the solution before).
-Use the [/li]
[li][/li][/ul]

Why it didn’t work (in the same order as the list above):

[ul][li]-Simply can’t figure out why it didn’t work.
-The code snippet I’ve found didn’t suit the fact that one of the code attributes changes on the fly.
-Can’t figure out how to do that properly; I don’t know how to make
[php]fuction bracketsInsideBrackets() {if (opsBraketsOfIF){}}[/php]
possible.
-Is it just Google Chrome or that button type doesn’t work?[/li]
[li][/li][/ul]

My code is the following (I hope I didn’t left anything important out):


<!--Javascript code-->
<!--Code to submit on Enter Key press (to ensure I don't need other submit button along with the textbar)-->
<SCRIPT TYPE="text/javascript">
<!--
function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}
//-->
</SCRIPT>

[php]
<?PHP
/*Code to make either compact or bulky*/
$show = $_POST['compact'];
$searched = $_POST['textbar'];


if ($show == 1)
{$displaysetting = inline;
$toggle=0;
}
else
{$displaysetting = none;
$toggle=1;
$UserServiceableMotivator="Here Be Dragons";};
?>
[/php]

<table summary="FOOBARRA DEVICE" title="Taken from some kind of 'Area 15'" align="center" border="0" width="50%">
<caption>
<?PHP
echo $UserServiceableMotivator;
?>
</caption>

<tr>
<td align="center">
<form action="index.php" method="POST">
<BUTTON TYPE=submit name="compact" title="<foobarra> Version 0.9" value="
<?PHP
echo $toggle;
?>
">
SEARCH</BUTTON>
</form>

</td>
</tr>
<tr>
<td>
<TABLE border="0" cellpadding='2' bgcolor="#000000" cellspacing='2' height='242' style='display:
<?PHP 
echo $displaysetting;
?>
'> <TR>
<TD abbr="TOA" height='90%'>
</TD></TR> 
<TR><TD><form action="index.php" method="POST" name="textbar">
<input type="text" title="<nome do sujeito aqui>" name="textbar" AUTOCOMPLETE=off size="50" onKeyPress="return submitenter(this,event)" value="the ability of this bar to change text on table data above has been disabled">
</form></TD></TR> 

</TABLE>
Sponsor our Newsletter | Privacy Policy | Terms of Service