Connecting Tech Pros Worldwide Help | Site Map

multiple image submit button problems

Ryan
Guest
 
Posts: n/a
#1: Jul 17 '05
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
Alvaro G Vicario
Guest
 
Posts: n/a
#2: Jul 17 '05

re: multiple image submit button problems


*** Ryan wrote/escribió (Fri, 23 Jan 2004 04:41:53 -0800):[color=blue]
> 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.[/color]

This could be a good start:

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



--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Sales at 3A Web Hosting
Guest
 
Posts: n/a
#3: Jul 17 '05

re: multiple image submit button problems


Hi Ryan
[color=blue]
> <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?[/color]

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
Chung Leong
Guest
 
Posts: n/a
#4: Jul 17 '05

re: multiple image submit button problems


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" <rcdetert@nospammerz.ucdavis.edu> napisal w wiadomosci
news:pan.2004.01.23.12.41.50.890560@nospammerz.ucd avis.edu...[color=blue]
> 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[/color]


Ryan
Guest
 
Posts: n/a
#5: Jul 17 '05

re: multiple image submit button problems


On Fri, 23 Jan 2004 16:26:29 +0000, Sales at 3A Web Hosting wrote:
[color=blue]
> Hi Ryan
>[color=green]
>> <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?[/color]
>
> 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
>
> }[/color]


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

Rahul Anand
Guest
 
Posts: n/a
#6: Jul 17 '05

re: multiple image submit button problems


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" <rcdetert@nospammerz.ucdavis.edu> wrote in message news:<pan.2004.01.23.12.41.50.890560@nospammerz.uc davis.edu>...[color=blue]
> 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[/color]
3A Web Hosting
Guest
 
Posts: n/a
#7: Jul 17 '05

re: multiple image submit button problems


Hi Ryan
[color=blue]
> 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.[/color]

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
Ryan
Guest
 
Posts: n/a
#8: Jul 17 '05

re: multiple image submit button problems


On Sat, 24 Jan 2004 13:59:42 +0000, 3A Web Hosting wrote:
[color=blue]
> Hi Ryan
>[color=green]
>> 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.[/color]
>
> 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....[/color]


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
3A Web Hosting
Guest
 
Posts: n/a
#9: Jul 17 '05

re: multiple image submit button problems


Hi Ryan
[color=blue]
>
> 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?[/color]

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
Newbie
 
Join Date: Jun 2006
Posts: 1
#10: Jun 30 '06

re: multiple image submit button problems


The submit button works, but in IE, the value attribute is ignored
Closed Thread