469,362 Members | 2,309 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

multiple image submit button problems

I currently have two image submit buttons. The code generated looks like
so:

<input type="image" src="button_in_cart.gif" border="0" alt="Add"
title="Add" name="btn_cart" value="buy">
<input type="image" src="modify.gif" border="0" alt="modify"
title="modify" name="btn_modify" value="modify">

In mozilla everything works great, but in Konqueror and MSIE the if
statement I'm using to detect which button was press does not work.

if (isset($HTTP_POST_VARS['btn_cart'])){ do stuff }

Does anyone know how to fix this without resorting to javascript?
thanx
-ryan
Jul 17 '05 #1
9 11292
*** Ryan wrote/escribió (Fri, 23 Jan 2004 04:41:53 -0800):
In mozilla everything works great, but in Konqueror and MSIE the if
statement I'm using to detect which button was press does not work.


This could be a good start:

<pre><?
print_r($_POST);
?>/pre>

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #2
Hi Ryan
<input type="image" src="button_in_cart.gif" border="0" alt="Add"
title="Add" name="btn_cart" value="buy">
<input type="image" src="modify.gif" border="0" alt="modify"
title="modify" name="btn_modify" value="modify">

In mozilla everything works great, but in Konqueror and MSIE the if
statement I'm using to detect which button was press does not work.

if (isset($HTTP_POST_VARS['btn_cart'])){ do stuff }

Does anyone know how to fix this without resorting to javascript?


Where are you checking 'btn_modify'? The line above only checks
'btn_cart'

My preferred method would be:-

<input type="image" src="button_in_cart.gif" border="0" alt="Add"
title="Add" name="action" value="buy">
<input type="image" src="modify.gif" border="0" alt="modify"
title="modify" name="action" value="modify">
if ($action == "buy") {

// do buy bit here

}
elseif ($action == "modify") {

// do modify bit here

}
--
Colin

3A Web Hosting Team
http://www.3awebhosting.co.uk
Jul 17 '05 #3
Wouldn't it make more sense to use the same name for both buttons?

<input type="image" src="button_in_cart.gif" border="0" alt="Add"
title="Add" name="btn_action" value="buy">
<input type="image" src="modify.gif" border="0" alt="modify"
title="modify" name="btn_action" value="modify">

if($_POST['btn_action'] == 'buy') ...

else if($_POST['btn_action'] == 'modify') ...

Uzytkownik "Ryan" <rc******@nospammerz.ucdavis.edu> napisal w wiadomosci
news:pa****************************@nospammerz.ucd avis.edu...
I currently have two image submit buttons. The code generated looks like
so:

<input type="image" src="button_in_cart.gif" border="0" alt="Add"
title="Add" name="btn_cart" value="buy">
<input type="image" src="modify.gif" border="0" alt="modify"
title="modify" name="btn_modify" value="modify">

In mozilla everything works great, but in Konqueror and MSIE the if
statement I'm using to detect which button was press does not work.

if (isset($HTTP_POST_VARS['btn_cart'])){ do stuff }

Does anyone know how to fix this without resorting to javascript?
thanx
-ryan

Jul 17 '05 #4
On Fri, 23 Jan 2004 16:26:29 +0000, Sales at 3A Web Hosting wrote:
Hi Ryan
<input type="image" src="button_in_cart.gif" border="0" alt="Add"
title="Add" name="btn_cart" value="buy">
<input type="image" src="modify.gif" border="0" alt="modify"
title="modify" name="btn_modify" value="modify">

In mozilla everything works great, but in Konqueror and MSIE the if
statement I'm using to detect which button was press does not work.

if (isset($HTTP_POST_VARS['btn_cart'])){ do stuff }

Does anyone know how to fix this without resorting to javascript?


Where are you checking 'btn_modify'? The line above only checks
'btn_cart'

My preferred method would be:-

<input type="image" src="button_in_cart.gif" border="0" alt="Add"
title="Add" name="action" value="buy">
<input type="image" src="modify.gif" border="0" alt="modify"
title="modify" name="action" value="modify">
if ($action == "buy") {

// do buy bit here

}
elseif ($action == "modify") {

// do modify bit here

}

Tried that, works fine in Mozilla but in Konqueror and Explorer it still
does not work.
Perhaps there is some bad html elsewhere that is messing things up. I'll
look for those errors when I get a chance.
-ryan

Jul 17 '05 #5
Sometimes the posted data does not have the value content of submit
button.
For example if the focus is in Inputbox and you press "enter" key. In
this case the first submit button will have focus.

So whatever you write in name, you need check the second submit button
in your if condition.

eg:

if(!empty($_POST))
{
// Form Posted

if(isset($_POST['second_button_name']))
/*
You can code this way if name is same for both button
if(isset($_POST['button_name'])
&& $_POST['button_name'] == "second_button_value")
*/
{
// Second button clicked

}
else
{
// First button clicked

}
}

--
Cheers,
Rahul Anand
"Ryan" <rc******@nospammerz.ucdavis.edu> wrote in message news:<pa****************************@nospammerz.uc davis.edu>...
I currently have two image submit buttons. The code generated looks like
so:

<input type="image" src="button_in_cart.gif" border="0" alt="Add"
title="Add" name="btn_cart" value="buy">
<input type="image" src="modify.gif" border="0" alt="modify"
title="modify" name="btn_modify" value="modify">

In mozilla everything works great, but in Konqueror and MSIE the if
statement I'm using to detect which button was press does not work.

if (isset($HTTP_POST_VARS['btn_cart'])){ do stuff }

Does anyone know how to fix this without resorting to javascript?
thanx
-ryan

Jul 17 '05 #6
Hi Ryan
Tried that, works fine in Mozilla but in Konqueror and Explorer it still
does not work.
Perhaps there is some bad html elsewhere that is messing things up. I'll
look for those errors when I get a chance.


Strange, it works fine here using Nutscrape, IE, Opera & kmeleon.
Have you tried an 'echo $action;' before the 'if' to make sur you are
picking up the variable?

Maybe add

if (!$action) {echo "NO VARIABLE PASSED";}

elseif ($action etc....

--
Colin

3A Web Hosting Team
http://www.3awebhosting.co.uk
Jul 17 '05 #7
On Sat, 24 Jan 2004 13:59:42 +0000, 3A Web Hosting wrote:
Hi Ryan
Tried that, works fine in Mozilla but in Konqueror and Explorer it still
does not work.
Perhaps there is some bad html elsewhere that is messing things up. I'll
look for those errors when I get a chance.


Strange, it works fine here using Nutscrape, IE, Opera & kmeleon.
Have you tried an 'echo $action;' before the 'if' to make sur you are
picking up the variable?

Maybe add

if (!$action) {echo "NO VARIABLE PASSED";}

elseif ($action etc....

I don't get it, the image button isn't getting passed into the form post
data. It isn't set, it isn't showing up at all, only works in mozilla.
Anyone offlist want to have a go at the html I'm generating?

-ryan
Jul 17 '05 #8
Hi Ryan

I don't get it, the image button isn't getting passed into the form post
data. It isn't set, it isn't showing up at all, only works in mozilla.
Anyone offlist want to have a go at the html I'm generating?


Email me a copy of your script and I'll have a look at it for you.

--
Colin

3A Web Hosting Team
http://www.3awebhosting.co.uk
Jul 17 '05 #9
The submit button works, but in IE, the value attribute is ignored
Jun 30 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Matt | last post: by
7 posts views Thread by b2b2u | last post: by
3 posts views Thread by D. Shane Fowlkes | last post: by
5 posts views Thread by Lau Lei Cheong | last post: by
2 posts views Thread by russiandevil | last post: by
4 posts views Thread by =?Utf-8?B?YzY3NjIyOA==?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.