2 submision buttons & IE problem
Hi, I'm having a problem with submiting a form.
My form has two submit buttons:
<input name='task' value='refresh' type='image'
src='images/osvjezi.jpg' />
<input name='task' value='add' type='image' src='images/osvjezi.jpg' />
When I submit data I get it from $_POST['task'] without problem in
Firefox but in IE there is no way.
I found one solution somewhere on the web:
<input name= 'task[0]' value='refresh' type='image'
src='images/osvjezi.jpg' />
<input name= 'task[0]' value='add' type='image'
src='images/osvjezi.jpg' />
To get $task value I should do following: $_POST['task'][0].
This solution worked fine for a while. Now it doesn't work again...
If firefox for $_POST['task'][0] i get good value but in IE I don't.
If I print_r$_POST['task'] in IE I get: [task] => Array ( [0] => 18 )
while I should be getting
[task] => Array ( [0] => refresh )
I could always name the buttons diferently but that isn't solution in
striving for...:)
Thanx
Re: 2 submision buttons & IE problem
On 22 Jan 2007 03:14:48 -0800, "luigi7up" <luigi7up [at] gmail.com> wrote:
>Hi, I'm having a problem with submiting a form.
>
>My form has two submit buttons:
>
><input name='task' value='refresh' type='image'
>src='images/osvjezi.jpg' />
><input name='task' value='add' type='image' src='images/osvjezi.jpg' />
>
>When I submit data I get it from $_POST['task'] without problem in
>Firefox but in IE there is no way.
>I found one solution somewhere on the web:
>
>
><input name= 'task[0]' value='refresh' type='image'
>src='images/osvjezi.jpg' />
><input name= 'task[0]' value='add' type='image'
>src='images/osvjezi.jpg' />
>
>To get $task value I should do following: $_POST['task'][0].
>
>This solution worked fine for a while. Now it doesn't work again...
>If firefox for $_POST['task'][0] i get good value but in IE I don't.
>
>If I print_r$_POST['task'] in IE I get: [task] => Array ( [0] => 18 )
>while I should be getting
>[task] => Array ( [0] => refresh )
>
>I could always name the buttons diferently but that isn't solution in
>striving for...:)
>
>Thanx
As I remember, when you use an image as a submit button, an array of
values is passed: both the x and y coodinates of the click and the
key name. Perhaps you are evaluating the wrong member of the array?
Re: 2 submision buttons & IE problem
luigi7up wrote:
> Hi, I'm having a problem with submiting a form.
>
> My form has two submit buttons:
>
> <input name='task' value='refresh' type='image'
> src='images/osvjezi.jpg' />
> <input name='task' value='add' type='image' src='images/osvjezi.jpg'
> />
>
> When I submit data I get it from $_POST['task'] without problem in
> Firefox but in IE there is no way.
> I found one solution somewhere on the web:
>
>
> <input name= 'task[0]' value='refresh' type='image'
> src='images/osvjezi.jpg' />
> <input name= 'task[0]' value='add' type='image'
> src='images/osvjezi.jpg' />
>
> To get $task value I should do following: $_POST['task'][0].
>
> This solution worked fine for a while. Now it doesn't work again...
> If firefox for $_POST['task'][0] i get good value but in IE I don't.
>
> If I print_r$_POST['task'] in IE I get: [task] => Array ( [0] => 18 )
> while I should be getting
> [task] => Array ( [0] => refresh )
>
> I could always name the buttons diferently but that isn't solution in
> striving for...:)
As far as I know this is how submitting with images works:
<input name="something"> will send something.x and something.y to the
server. There _might_ be a 'pure' 'something', but as far as I know this is
optional/not strictly necessary, well I'm too laxy to read the
documentation, but at least it's not always sent, therefor unreliable.
In PHP, something.x and something.y will be transformed to something_x and
something_y to form valid keys for the POST array. These two values will
contain the coordinates clicked.
If you want another value then the clicked coordinates, you shouldn't use
type="image", but style an <input type=submit> or perhaps use a <button>
Grtz,
--
Rik Wasmus
Re: 2 submision buttons & IE problem
I tried this:
<button type=3D'submit' name=3D'task[0]' value=3D'refresh' title=3D'dodaj u
ko=9Aaricu' >Bla Bla</button>
<button type=3D'submit' name=3D'task[0]' value=3D'add' title=3D'dodaj u
ko=9Aaricu'>Bla</button>"
still no result in IE.
There ):
Rik wrote:
> luigi7up wrote:
> > Hi, I'm having a problem with submiting a form.
> >
> > My form has two submit buttons:
> >
> > <input name=3D'task' value=3D'refresh' type=3D'image'
> > src=3D'images/osvjezi.jpg' />
> > <input name=3D'task' value=3D'add' type=3D'image' src=3D'images/osvjezi=
..jpg'
> > />
> >
> > When I submit data I get it from $_POST['task'] without problem in
> > Firefox but in IE there is no way.
> > I found one solution somewhere on the web:
> >
> >
> > <input name=3D 'task[0]' value=3D'refresh' type=3D'image'
> > src=3D'images/osvjezi.jpg' />
> > <input name=3D 'task[0]' value=3D'add' type=3D'image'
> > src=3D'images/osvjezi.jpg' />
> >
> > To get $task value I should do following: $_POST['task'][0].
> >
> > This solution worked fine for a while. Now it doesn't work again...
> > If firefox for $_POST['task'][0] i get good value but in IE I don't.
> >
> > If I print_r$_POST['task'] in IE I get: [task] =3D> Array ( [0] =3D> 1=
8 )
> > while I should be getting
> > [task] =3D> Array ( [0] =3D> refresh )
> >
> > I could always name the buttons diferently but that isn't solution in
> > striving for...:)
>
>
> As far as I know this is how submitting with images works:
> <input name=3D"something"> will send something.x and something.y to the
> server. There _might_ be a 'pure' 'something', but as far as I know this =
is
> optional/not strictly necessary, well I'm too laxy to read the
> documentation, but at least it's not always sent, therefor unreliable.
>
> In PHP, something.x and something.y will be transformed to something_x and
> something_y to form valid keys for the POST array. These two values will
> contain the coordinates clicked.
>
> If you want another value then the clicked coordinates, you shouldn't use
> type=3D"image", but style an <input type=3Dsubmit> or perhaps use a <butt=
on>
>
> Grtz,
> --
> Rik Wasmus
Re: 2 submision buttons & IE problem
luigi7up wrote:
> I tried this:
>
> <button type='submit' name='task[0]' value='refresh' title='dodaj u
> košaricu' >Bla Bla</button>
> <button type='submit' name='task[0]' value='add' title='dodaj u
> košaricu'>Bla</button>"
>
> still no result in IE.
Please don't topppost. I'll forgive you this time as I was too lazy to
check my abviously now faulty answer :-P.
Indeed, running the following:
<?php
readfile('php://input');
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<button type='submit' name='task' value='refresh' title='dodaj u
košaricu' >Bla Bla</button>
<button type='submit' name='task' value='add' title='dodaj u
košaricu'>Bla</button>
</form>
Clicking the first button:
Results in MSIE:
task=Bla+Bla&task=Bla
In Firefox:
task=refresh
So, 2 differences: the one posts both _contents_ of 'task', the later
overriding the first, the other only posts the clicked button with the
_value_.
I don't know which one's at fault here, as I never use the <button>, and
now I know why :-).
The other option I gave was just to use a styled <input type="submit">, now
I know this one works without a doubt, as I use it regulary.
--
Rik Wasmus
Re: 2 submision buttons & IE problem
"Please don't topppost. I'll forgive you this time as I was too lazy to
check my abviously now faulty answer :-P. "
I didn't get this one...
Thanks for your reply...
I think I was using your <input type='submit'> way but it misteriously
stopped working.
Now I tried it again adn it works just fine...
Thank you...
Re: 2 submision buttons & IE problem
luigi7up wrote:
> "Please don't topppost. I'll forgive you this time as I was too lazy
> to check my abviously now faulty answer :-P. "
>
> I didn't get this one...
Google, second & third result:
http://www.xs4all.nl/~sbpoley/toppost.htm
http://www.html-faq.com/etiquette/?toppost
--
Rik Wasmus