Click to See Complete Forum and Search --> : IE and forms
bokeh
01-28-2006, 11:02 AM
Very strange:<form action="" method="post">
<input type="text" name="text_field">
<input type="submit" name="submit" value="submit">
</form>
<pre><?php print_r($_POST); ?></pre> If I enter text into the text field and then press <enter> it prints:Array
(
[text_field] => testing
)whereas if I press the submit button it printsArray
(
[text_field] => testing
[submit] => submit
)
If there are multiple fields though $_POST['submit'] is always set.
Is there any logic to this behaviour?
chazzy
01-28-2006, 11:11 AM
Yes.
in IE, if you only have one text box, it acts as a submit button when the enter key is pressed. It doesn't pass through the submit button basically. When you have more than one field, though, it has to pass through the submit button to capture the whole form (or else if you were on the first box and hit enter, this would say that only up to the first box gets sent)
I think in multi textbox forms, IE doesn't allow enter key for submit as well, might vary on version though.
bokeh
01-28-2006, 11:37 AM
I think in multi textbox forms, IE doesn't allow enter key for submit as well, might vary on version though.The enter key submits from any text boxes in IE6 (and firefox). <textarea> works different because line feeds are allowed.
Anyway I just though I'd mention this because it is such an annoying fault. I had if(isset($_POST['submit'])){ in something I was writing and it took about 15 minutes to track down why it didn't work in IE.
chazzy
01-28-2006, 11:47 AM
The enter key submits from any text boxes in IE6 (and firefox). <textarea> works different because line feeds are allowed.
Anyway I just though I'd mention this because it is such an annoying fault. I had if(isset($_POST['submit'])){ in something I was writing and it took about 15 minutes to track down why it didn't work in IE.
Hmmm I had read differently, but ok! Thanks for the heads up, I usually check for a form field anyways, just force of habit I suppose.