Q: possible Bug in IE 6 post more than succesfull control when using button tag

T

Tom Asken

Short version: IE 6.0 wrongly posts <button ..> value. Internet
Explorer should only post the value of the clicked submit button - but
IE 6 posts the value of several submit buttons if they have the same
name

Long version:

I have a form with several Buttons with the same name and different
values. According to the w3c only successful controls supposed to be
submitted:

"A successful control is "valid" for submission. Every successful
control has its control name paired with its current value as part of
the submitted form data set. A successful control must be defined
within a FORM element and must have a control name. ..."

And

"If a form contains more than one submit button, only the activated
submit button is successful."

see at http://www.w3.org/TR/html401/interact/forms.html#successful-controls


So they speak of "submit button". The tag "<input type='submit'
name='myButt' ...>" supposed to be the same as "<button type='submit'
name="myButt' ..>foo</button>" accept for richer layout:


So i assume that only the clicked <button> supposed to be posted. Well
mozilla 1.7 does it right. IE 6 makes it wrong.

It is getting really annoying with this old (2001 ?!) Internet
Explorer 6.0

Here is an exmaple:
-------------------------------------------------------------------

<FORM action="" method="post">

<button type="submit" name="IEmyButt"
value="A is firstButton">A</button>

<button type="submit" name="IEmyButt"
value="B is secondButton">B</button>
</FORM>



-------------------------------------------------------------------


PHP show post values
<?
//php
echo "<span style='color:red'>Post<pre>"; print_r($_POST); echo
"</pre></span>";
?>



-------------------------------------------------------------------


Thanks.

Best Regards
 
S

SpaceGirl

Tom Asken said:
Short version: IE 6.0 wrongly posts <button ..> value. Internet
Explorer should only post the value of the clicked submit button - but
IE 6 posts the value of several submit buttons if they have the same
name

Long version:

I have a form with several Buttons with the same name and different
values. According to the w3c only successful controls supposed to be
submitted:

<snip>

Make sure you dont have overlapping form elements?
 
M

Markus Ernst

[...]
Here is an exmaple:
-------------------------------------------------------------------

<FORM action="" method="post">

<button type="submit" name="IEmyButt"
value="A is firstButton">A</button>

<button type="submit" name="IEmyButt"
value="B is secondButton">B</button>
</FORM>



-------------------------------------------------------------------


PHP show post values
<?
//php
echo "<span style='color:red'>Post<pre>"; print_r($_POST); echo
"</pre></span>";
?>

If you use PHP you can easily work around this using different button names:

<?php
if(isset($_POST['button1'])) $value = $_POST['button1'];
else if(isset($_POST['button2'])) $value = $_POST['button2'];
else $value = "my custom value";
?>

Like that you also have no problem when no button is clicked at all and the
form is submitted by hitting enter.

HTH
Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top