RE: [PHP] RE: multiple submit buttons

From: Date: Fri, 31 Aug 2001 17:50:17 +0000
Subject: RE: [PHP] RE: multiple submit buttons
Groups: php.general 
Request: Send a blank email to php-general+get-65529@lists.php.net to get a copy of this message
Tim Ward wrote: > Be careful using values of submit buttons ... if the user hits return instead of clicking one of the buttons you won't get anything. If you want a default value try a hidden field before the submits with same name. > Tim, thanks for the tip. I had heard of this behavior before, but never witnessed it. Today I wrote a test form with 1 text field and 1 submit, and it did do this: when I submitted via return, the submit field was not posted. However, when I added a second text field to the form, the submit did get posted. I was careful that the focus was still in the text field, and not on the button, when I hit return. Any ideas on why this inconsistency? Just curious. Since it is inconsistent, your point is important and well-taken. My code is below if anyone wants to play. Kirk submit.php ---------- <HTML><HEAD></HEAD><BODY> <FORM ACTION="submitRun.php" METHOD="POST"> <INPUT TYPE="text" name="test"><br> <!--<input type="text" name="test2"><br>--> <!--<INPUT TYPE="hidden" name="submit" value="Yes">--> <INPUT TYPE="SUBMIT" name="submit" value="Yes"> <INPUT TYPE="SUBMIT" name="submit" value="No"> </FORM></BODY></HTML> submitRun.php ------------- <? while(list($key,$val)=each($HTTP_POST_VARS)) { echo "key $key = $val <br>"; } ?>

« previous php.general (#65529) next »