Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    several actions with one submit button

    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:
    Code:
    <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>

  • #2
    New Coder
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •