You are here: Re: Two Submit buttons on one form « PHP Programming Language « IT news, forums, messages
Re: Two Submit buttons on one form

Posted by lvaro G. Vicario on 01/12/08 13:28

*** ktstone2678@gmail.com escribió/wrote (Sat, 12 Jan 2008 04:40:39 -0800
(PST)):
> I have a basic shopping cart setup, currently the user clicks a button
> to remove an item from the cart. The form action posts to itself in
> order to update the item list.
>
> Is it possible to have another button in the same form that posts to a
> different location?
>
> Please hold your comments if they're not constructive. I am aware of
> the existence of Google, it just hasn't worked for me here.

I'll personally give buttons a name and make them all submit to self page
(see sample code on bottom). Then, check which name exists and act
accordingly: header('Location: ...') is your friend.

Make sure it's cross browser (IE has some problems if buttons are
type="image") and make sure of what happens when user hits the "enter" key.





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

<?

echo '<xmp>$_POST: '; var_dump($_POST); echo '</xmp>';

?>

<form action="" method="post">
<input name="remove" type="submit" value="Remove">
<input name="checkout" type="submit" value="Checkout">
</form>

</body>
</html>


--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor austrohúngaro: http://www.demogracia.com
--

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация