2016-04-05 17:09 阅读 70


This question is an exact duplicate of:

I have built an order form in which the user would enter in a company name, last name, email and an address and an optional checkbox for shipping priced at $19.99. I downloaded the paypal payment form module for my dreamweaver cs5 program which converts the form into a paypal form.

The nice thing about this program is that it automatically creates a mysql database with all the input fields when a person clicks the "pay now" button It also generates the files automatically in a folder called "PPPaymentForm" which i then upload in the root of my site and gives me a backend as well so i can monitor all the payment transactions.

So back to my original issue, i need some way so that if a person decides to click the checkbox which is set at $19.99, that it will automatically add to the price which is set in an hidden input named "hdwppamount" where the value is set to $175.00. So therefor if the shipping option is clicked, the person would click the "Pay Now" button and would be redirected to the paypal payment page, with the new calculated price at $194.99.

I am not proficient with javascript or php, and tried many functions myself but nothing worked. Could someone help me with this please?

Thank You

<form action="PPPaymentForm/PPPaymentForm.php" method="post" name="topchoiceform" id="topchoiceform">
  <input placeholder="Company Name" type="text" name="companyname" required>
  <input placeholder="First Name" type="text" name="firstname" required>
  <input placeholder="Last Name" type="text" name="lastname" required>
  <input placeholder="Email" type="email" name="email" required>
  <input placeholder="Address" type="text" name="address" required>
  <input type="checkbox" id="shipping" name='shipping' />$optional Shipping($19.99)
  <button name="submit" type="submit">Pay Now</button>

  <input type="hidden" name="hdwtablename" id="hdwtablename" value="1">
  <input type="hidden" name="hdwppproductname" id="hdwppproductname" value="Basic 175 Plan">
  <input type="hidden" name="hdwppamount" id="hdwppamount" value="175">
  <input type="hidden" name="hdwppcurrency" id="hdwppcurrency" value="USD">
  <input type="hidden" name="hdwpplanguage" id="hdwpplanguage" value="en_US">
  <input type="hidden" name="hdwok" id="hdwok" value="">
  <input type="hidden" name="hdwemail" id="hdwemail" value="">
  <input type="hidden" name="hdwnook" id="hdwnook" value="http://">
  <input type="hidden" name="hdwactivation_email" id="hdwactivation_email" value="email">
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    douzhan3900 douzhan3900 2016-04-05 18:58

    First, we detect when the shipping checkbox is changed, then we check to see if it is in a checked state. If it is in a checked state, we add the shipping cost to the hidden text box. We also need to reset the value if the user changes their mind about shipping so you need a basic IF ELSE condition on it.

    Try this:

        var hdwppamount = Number($("#hdwppamount").val())
        var shippingcost = 19.99;
         if (this.checked) {
         } else {


    点赞 评论 复制链接分享