|
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]
|