...

View Full Version : several actions with one submit button



captainmeowtron
07-22-2009, 08:45 PM
I basically have no idea what I'm doing. This is in a popup window, and what I want is for the submit button to populate an item to the shopping cart, close the popup window, and return to the parent url (in that order.) The problem I'm having is that I can either get items to show up in the cart, or get the popup to close and return to the url. Not both. Here's what I've got:

<html>
<head>
<title>jewelery</title>
<STYLE type="text/css">
<!--
A { text-decoration:none }
-->
</STYLE>
</head>
<body bgcolor="#000000" TEXT="000000" body link="#000000" vlink="#000000" alink="#000000">
<table border="0" bordercolor="" style="background-color:#000000" width="100%" cellpadding="" cellspacing="">
<tr>
<td><img src="1.jpg"></td>

<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>
<form method="post" action="ShoppingCart.php" onsubmit="window.opener.location.href='ShoppingCart.php'; window.close();">
[item description]
<input name="cmd" type="hidden" id="cmd" value="1" />
<input type="submit" name="Submit" value="Add To Cart" / >
</td>
</tr>
</table>
</body>
</html>

celsoendo
07-23-2009, 03:22 AM
You can't close the window before posting the form. You must close the popup after ShoppingCart.php responds "ok"... without this you can't guarantee that the form will be posted correctly.

To put more than 1 action on a submit button, change it to a regular button (type="button") and you can link an event to onclick of this button to call a function to do all the actions needed (submit the form, change the opener location, but not close the actual popup because the problem above).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum