RE: [PHP] RE: multiple submit buttons
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 -- HTMLHEAD/HEADBODY FORM ACTION=submitRun.php METHOD=POST INPUT TYPE=text name=testbr !--input type=text name=test2br-- !--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; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: multiple submit buttons
On Wednesday 29 August 2001 10:09, Justin French wrote: I noticed this chunk of code in a site the other day: input type=Submit name=btn value=Yes input type=Submit name=btn value=No My GUESS is that if i click the Yes button, I magically get $btn = Yes as a var is the receieving PHP script. I was just about to test this, when I realised that (from what I can tell) multiple submits are not supported by CGI spec. So, even if it works on my browser/platform/server/php combination, can I be sure it'll work faithfully on all environments? This has nothing to do with the CGI standard. It has to do with the HTML standard, which says that: If a form contains more than one submit button, only the activated submit button is successful. This appears on: http://www.w3.org/TR/html4/interact/forms.html#h-17.13 Note that the CGI standard really has little to do with PHP unless you compiled in CGI mode. Some behaviour was inherited from it, but really, all that is relevant to us is the HTML and the HTTP standards. Herouth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] RE: multiple submit buttons
As far as any CGI is concerned there is only one submit, The one that is pressed. The other one is simply not posted. But 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 Ward -- From: Justin French [SMTP:[EMAIL PROTECTED]] Sent: 29 August 2001 08:10 To: php Subject: multiple submit buttons Hi all, I noticed this chunk of code in a site the other day: input type=Submit name=btn value=Yes input type=Submit name=btn value=No My GUESS is that if i click the Yes button, I magically get $btn = Yes as a var is the receieving PHP script. I was just about to test this, when I realised that (from what I can tell) multiple submits are not supported by CGI spec. So, even if it works on my browser/platform/server/php combination, can I be sure it'll work faithfully on all environments? Should I be worried about what the browser sends, or what PHP does with it, etc etc? Has anyone doen some serious testing on this? Good or bad stories? Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] RE: multiple submit buttons
Maybe it is not supported by CGI but that doesn't mean it is not supported by the browser. There is no reason for IE of course to say it hurts. When you click first button bth is Yes, click on second button bth is No. Also you can have several buttons everyone of them do submit with different names, so if one button is named edit, other - delete. When a user clicks delete button PHP put in $HTTP_GET_VARS or $HTTP_POST_VARS delete index. There is no edit index. Andrey Hristov IcyGEN Corporation http://www.icygen.com 99% - Original Message - From: Tim Ward [EMAIL PROTECTED] To: php [EMAIL PROTECTED]; 'Justin French' [EMAIL PROTECTED] Sent: Wednesday, August 29, 2001 3:52 PM Subject: [PHP] RE: multiple submit buttons As far as any CGI is concerned there is only one submit, The one that is pressed. The other one is simply not posted. But 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 Ward -- From: Justin French [SMTP:[EMAIL PROTECTED]] Sent: 29 August 2001 08:10 To: php Subject: multiple submit buttons Hi all, I noticed this chunk of code in a site the other day: input type=Submit name=btn value=Yes input type=Submit name=btn value=No My GUESS is that if i click the Yes button, I magically get $btn = Yes as a var is the receieving PHP script. I was just about to test this, when I realised that (from what I can tell) multiple submits are not supported by CGI spec. So, even if it works on my browser/platform/server/php combination, can I be sure it'll work faithfully on all environments? Should I be worried about what the browser sends, or what PHP does with it, etc etc? Has anyone doen some serious testing on this? Good or bad stories? Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]