Jump to content

Recommended Posts

Hi,

 

I have a website that has cart and checkout and im rying to submit a form after i have a javascript popup asking to confirm order submit and clear cart, my form has 3 differant buttons and based on which button the form is submitted with the page does differant things, i just cant seem to get it to work as javascript tends to just "submit" the form not submit it by the id/name of the button i tried to submit with. heres my code.

 

this is the form, ive cut alot of code out as its about 100 lines long

 

<form id="order" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">

<a href="#" class="linkButton" onclick="clear_confirm()">Empty Cart</a>
<input type="submit" class="formButton" name="update" value="Update Cart"  />
<input type="submit" onclick="order_confirm()" value="Place Order" name="place_order" class="formButton" />

</form>

 

heres the javascript

 

 

function clear_confirm()
{
var r=confirm("Are you sure you want to empty the cart?")
if (r==true)
  {
  window.location="index.php?location=cart.php&action=empty";
  }
else
  {
  }
}

function order_confirm()
{
var r=confirm("Are you sure you want to place the order")
if (r==true)
  {
  document.forms["order"].submit();
  }
else
  {
  }
}

 

the clear and update work fine because the clear redirects to a new page, and the update self submits without going via javascript, but when i click on order confirm the java popup appears for confirmation but the page doesnt get submitted, when the page is submitted via order_confirm it should pick up this part

 

if(isset($_POST['place_order']))
{
echo "place order";
}

 

am i missing something in the javascript to make it submit the form?

 

thanks in advance

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.