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
    Jul 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need help to fix simple form

    Please help if you can.
    My problem is that i have simple paypal form. When user select 10 accounts then below textbox shows amount to be paid. But when i click at paypal it again multiply with accounts and shows multiple amount at paypal page.

    For example if you select 10 then amount will be 18.5$ but after clicking at pay button it shows amount at paypal page $185.00




    Code:
    <body>
    <form name="frm1" action="https://www.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="cmd" value="_xclick">
        <input type="hidden" name="business" value="accounts@freelanceswitch.com"><br />
        <strong>How Many Acounts you want</strong>
    <select name="quantity" onchange="calculate()" id="quantity">
       		<option value="5">5</option>
       		<option value="10">10</option>
       		<option value="15">15</option>
       		<option value="20">20</option>
       		<option value="25">25</option>
       		<option value="30">30</option>
      </select>
    <br />
        <input type="hidden" name="no_shipping" value="0">
        <input type="hidden" name="no_note" value="1">
        <input type="hidden" name="currency_code" value="USD">
        <input type="hidden" name="lc" value="AU">
        <input type="hidden" name="bn" value="PP-BuyNowBF">
    	<input type="hidden" name="return" value="http://net.tutsplus.com/payment-complete/">
    	<br />
    	<p>$
          <input type="text" name="amount" id="amount" value="0" readonly="readonly"/>
      <br />
    
          <input type="submit" value="Pay with PayPal!">
      </p>
    </form>
    <script type="text/javascript">
    	function calculate (){
    		ac=document.getElementById('quantity').value;
    		var z=1.85;
    		
    		total =ac*z;
    		document.frm1.amount.value=total;	
    		}
    	
    </script>
    </body>

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,087
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    You will need to replace the form tag from this example
    and add whatever validation you wish before the form information is submitted,
    but this appears to calculate correctly.
    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <title> Untitled </title>
    <script type="text/javascript">
    function validation() {
      calculate();
      return false;  // change to true after testing
    }
    </script>
    
    </head>
    <body>
    
    <!--
    <form name="frm1" action="https://www.paypal.com/cgi-bin/webscr" method="post">
    -->
    <form name="frm1" action="javascript:alert('Success')" method="post" onsubmit="return validation()">
    
       <input type="hidden" name="cmd" value="_xclick">
       <input type="hidden" name="business" value="accounts@freelanceswitch.com"><br />
       <strong>How Many Acounts you want</strong>
    <select name="quantity" onchange="calculate()" id="quantity">
       <option value="5">5</option>
       <option value="10">10</option>
       <option value="15">15</option>
       <option value="20">20</option>
       <option value="25">25</option>
       <option value="30">30</option>
      </select>
    <br />
       <input type="hidden" name="no_shipping" value="0">
       <input type="hidden" name="no_note" value="1">
       <input type="hidden" name="currency_code" value="USD">
       <input type="hidden" name="lc" value="AU">
       <input type="hidden" name="bn" value="PP-BuyNowBF">
       <input type="hidden" name="return" value="http://net.tutsplus.com/payment-complete/">
       <br />
       <p>$
       <input type="text" name="amount" id="amount" value="0" readonly="readonly"/>
      <br />
       <input type="submit" value="Pay with PayPal!">
      </p>
    </form>
    
    <script type="text/javascript">
    function calculate (){
      ac=document.getElementById('quantity').value;
      var z=1.85;
    		
      total =ac*z;
      document.frm1.amount.value=total;	
    }
    	
    </script>
    </body>
    </html>


  •  

    Posting Permissions

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