roopurt18 Posted November 15, 2007 Share Posted November 15, 2007 Not sure how many people are aware of this, but I just spent 10 minutes going "WTF?!" Simple form with a text field and a button with name='add_group' On the processing page is a check: if($this->_view == 'add_group' && isset($_POST['add_group'])){ // ... } Basically the form processor checks that we're on the right page and we got here from the correct submit button. It wasn't working on IE6 because I was hitting enter instead of clicking the button. I would type in the text field, hit enter, and since I didn't technically click the button, 'add_group' wasn't set in $_POST. Of course, FF behaved properly. Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/ Share on other sites More sharing options...
kellz Posted November 16, 2007 Share Posted November 16, 2007 I hate IE, it takes forever to load and even longer to exit it.. So I just use firefox, even my school uses firefox. Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-392506 Share on other sites More sharing options...
TheFilmGod Posted November 16, 2007 Share Posted November 16, 2007 So I just use firefox, even my school uses firefox. Really? That's odd. That's never the case! Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-392510 Share on other sites More sharing options...
neylitalo Posted November 16, 2007 Share Posted November 16, 2007 So I just use firefox, even my school uses firefox. Really? That's odd. That's never the case! My university strongly advises all members of the campus community against using IE. It wasn't working on IE6 because I was hitting enter instead of clicking the button. I would type in the text field, hit enter, and since I didn't technically click the button, 'add_group' wasn't set in $_POST. Have you found a fix that doesn't hinge on not using IE, or otherwise forcing the user to make the change? If not, how about this: Is it necessary to check for the submit button? Instead of checking: if(isset($_POST['add_group'])) would it work to check this? if(isset($_POST['text_entry_field'])) You'd have to make sure that the name of the text entry field is unique, and that it would indicate that you're coming from the correct form. Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-392517 Share on other sites More sharing options...
roopurt18 Posted November 16, 2007 Author Share Posted November 16, 2007 Have you found a fix that doesn't hinge on not using IE, or otherwise forcing the user to make the change? Nope, I'm mostly over it now too. Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-392537 Share on other sites More sharing options...
fenway Posted November 19, 2007 Share Posted November 19, 2007 It wasn't working on IE6 because I was hitting enter instead of clicking the button. I would type in the text field, hit enter, and since I didn't technically click the button, 'add_group' wasn't set in $_POST. Of course, FF behaved properly. According to the HTML spec: If a control doesn't have a current value when the form is submitted, user agents are not required to treat it as a successful control And since the default value for a button is nothing, IE is following the spec. Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394431 Share on other sites More sharing options...
roopurt18 Posted November 19, 2007 Author Share Posted November 19, 2007 I'd have to disagree. Inputs of type button or submit are almost always given a value attribute, so the question is when a form is submitted do you send all of the button / submit inputs or just the one that was depressed? Most browsers default to the one that was depressed. So when submitting a form with a single button / submit input, we'd expect to see it in $_POST. Now, if you have a form that consists purely of a text input and a submit button, does the specification say that pressing [enter] while focus is in the text input that the form should be submitted? I would guess that it doesn't, but most browsers do support that behavior. So, if pressing enter causes the form to be submitted, why would the button not be sent as if it were clicked? It just seems counter-intuitive to me. Also, it's not mentioned in my OP, but the submit button does have a value attribute set. MS does follow outside specifications in some areas, but I don't think this is one of them. Also, when they do decide to follow standards, they usually pick the most obscure parts of the specification that make the developers' lives torture. Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394598 Share on other sites More sharing options...
emehrkay Posted November 19, 2007 Share Posted November 19, 2007 Hmmm, i just did a test and it works across the board <?php echo '<pre>', print_r($_POST), '</pre>' ?> <form action="" method="post"> <input type="text" value="" name="field_1" /> <input type="text" value="" name="field_2" /> <input type="text" value="" name="field_3" /> <input type="text" value="" name="field_4" /> <input type="submit" value="Pressed or Not" name="form_button" /> <button name="test button" >tasdfa</button> </form> And I am not sure if your button type was a submit or not, but you did say if you press it and didnt mention any javascript. It works fine in IE for me Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394760 Share on other sites More sharing options...
roopurt18 Posted November 19, 2007 Author Share Posted November 19, 2007 Does exactly what I described here: http://ns2271.serverpowered.net/test/ietest.php Type hello in the box and immediately hit enter. Then type hello in the box and click on the button. <?php if(!empty($_POST)){ echo '<pre>' . print_r($_POST, true) . '</pre>'; } echo <<<HTML <form action="" method="post"> <input type="text" name="the_text" size="16"/> <input type="submit" name="the_submit" value="Go" /> </form> HTML; ?> Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394775 Share on other sites More sharing options...
emehrkay Posted November 20, 2007 Share Posted November 20, 2007 Looks like if you add another input it works as expected. I understand why people hate microsoft Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394817 Share on other sites More sharing options...
teng84 Posted November 20, 2007 Share Posted November 20, 2007 Looks like if you add another input it works as expected. I understand why people hate microsoft i guess IE defeats FF in this case (nice roopurt ) thumbs up for IE in this case Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394827 Share on other sites More sharing options...
neylitalo Posted November 20, 2007 Share Posted November 20, 2007 Looks like if you add another input it works as expected. I understand why people hate microsoft i guess IE defeats FF in this case (nice roopurt ) thumbs up for IE in this case Um... no, IE loses. It behaves differently if you have two inputs than with one input. Since when is that intuitive? Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394835 Share on other sites More sharing options...
Azu Posted November 20, 2007 Share Posted November 20, 2007 Have you found a fix that doesn't hinge on not using IE, or otherwise forcing the user to make the change?Speaking of which.. I wander how long it will be until somebody someone uses the security problems in IE to make it uninstall itself and install Firefox when you visit their site, automatically. That would be so awesome! Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394844 Share on other sites More sharing options...
teng84 Posted November 20, 2007 Share Posted November 20, 2007 well my point is that you dont press that button so why would be included in your post data... like check boxes and radio button if you dont press them they will not become part of the post data.. so this time i go with IE Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394846 Share on other sites More sharing options...
Azu Posted November 20, 2007 Share Posted November 20, 2007 Huh? Pressing enter is the same as clicking submit (unless it's a <textarea>). Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394895 Share on other sites More sharing options...
teng84 Posted November 20, 2007 Share Posted November 20, 2007 Huh? Pressing enter is the same as clicking submit (unless it's a <textarea>). what if you 3 buttons ??? in single submit button in FF yes but in IE you have to be sure that the pointer or focus form is in that button before you hit enter for you to be able to get the value of that button.. try the sample the roopurt provided Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394913 Share on other sites More sharing options...
Azu Posted November 20, 2007 Share Posted November 20, 2007 I think there is usually only one submit button when there is no <textarea> involved. I think it is basically a standard to only have one submit button in such cases except in very rare exceptions. Or if the form itself is comprised of nothing but submit buttons (in which case it's kind of moot since hitting enter will only submit the one you click on, and clicking on it will submit it lol) Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-394919 Share on other sites More sharing options...
fenway Posted November 20, 2007 Share Posted November 20, 2007 I'd have to disagree. Inputs of type button or submit are almost always given a value attribute, so the question is when a form is submitted do you send all of the button / submit inputs or just the one that was depressed? Most browsers default to the one that was depressed. So when submitting a form with a single button / submit input, we'd expect to see it in $_POST. Now, if you have a form that consists purely of a text input and a submit button, does the specification say that pressing [enter] while focus is in the text input that the form should be submitted? I would guess that it doesn't, but most browsers do support that behavior. So, if pressing enter causes the form to be submitted, why would the button not be sent as if it were clicked? It just seems counter-intuitive to me. Also, it's not mentioned in my OP, but the submit button does have a value attribute set. MS does follow outside specifications in some areas, but I don't think this is one of them. Also, when they do decide to follow standards, they usually pick the most obscure parts of the specification that make the developers' lives torture. That doesn't make sense in the general case. All buttons have "values" -- that's the only way to specify their label. However, you wouldn't want all "unclicked/unpressed" buttons to be submitted as successful name/value pairs, right? Just because you expect it to be submitted doesn't mean the browser has been to psychic -- and spec doesn't require it. As for the submit-on-enter argument, that's another can of worms entirely. You want a single submit button to be treated as a magical auto-valued auto-clicked button if and only if it's the only button in the form... that's what the spec doesn't agree with. All buttons are created equal. Quote Link to comment https://forums.phpfreaks.com/topic/77542-watch-out-for-this-ie-behavior/#findComment-395181 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.