Form processing differences between Firefox and IE

Form processing differences between Firefox and IE

by Paul Vaughan -
Number of replies: 4

I have a form in a block which works just as expected in Firefox but fails in IE. I believe it is a quirk in the way IE passes form data, but I'm not wholly sure.

This bit is the basis of the form HTML, much simplified. As you can see, I use a series of images as the 'submit' buttons. There are four in total, all with the same name 'vote' but with different values.

<form method="post" action="vote.php">
<input type="hidden" name="cid" value="2" />
<div id="vote_images">
<input type="image" name="vote" value="1" src="/img/1.png" />
<input type="image" name="vote" value="2" src="/img/2.png" />
<input type="image" name="vote" value="3" src="/img/3.png" />
<input type="image" name="vote" value="4" src="/img/4.png" />
</div>
</form>

So I am expecting a 'cid' field as well as a 'vote' field, both with numerical values. In the action script, I have the following two lines:

$cid = required_param('cid', PARAM_INT);
$vote = required_param('vote', PARAM_INT);

In Firefox, the form is processed normally, but in IE the user gets the error "A required parameter (vote) was missing", which makes me think it's not being passed properly. I'm wondering if this could be due to having four form elements with the same name, which Ffx accepts but IE does not? Only one of them is clicked on per form.

Help and pointers greatly appreciated. smile

Average of ratings: -
In reply to Paul Vaughan

Re: Form processing differences between Firefox and IE

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Image submits generate values vote.x, vote.y, equal to the pixel you clicked on, and not plain old 'vote'. This works cross-browser. Unfortunately, value= does not.

To fix this change your script to use the name= parameter to store the value as well, e.g. use the name vote1, and then look for the optional parameter vote1.x, vote2.x, etc to decide what they voted for.

When debugging form problems, use tools to see what the browser is sending. Easiest way to do this is change the form from POST to GET so you can just see it in the URL for all browsers. For POST forms there are tools available (especially in firefox) or you can use a network traffic analyser such as WireShark.

--sam
In reply to sam marshall

Re: Form processing differences between Firefox and IE

by Paul Vaughan -
Thanks Sam, changing POST to GET would have been an easy win smile I'll look into WireShark, thanks for the heads-up, but I wish something like Firebug was available in IE.
In reply to Paul Vaughan

Re: Form processing differences between Firefox and IE

by Paul Vaughan -

Firefox is returning this:

Array ( [cid] => 2 [note] => [vote_x] => 12 [vote_y] => 12 [vote] => 1 )

...and IE is returning this:

Array
(
 [cid] => 2
 [note] =>
 [vote_x] => 12
 [vote_y] => 12
)

So I'm getting the x and y coordinate of the mouseclick but IE's not returning the vanilla variable on it's own. sad

Found a way to scrub 'vote_x' and 'vote_y' out of the data the form sends, but this doesn't magically bring back 'vote'.