Need help to fix simple form

Discussion in 'JavaScript' started by naumanahmed19, Aug 22, 2011.

  1. #1
    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




    <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>
    Code (markup):
     
    naumanahmed19, Aug 22, 2011 IP
  2. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #2
    try this..

    <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(this.value)" 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 (value){
    		ac=value;
    		var z=1.85;
    		
    		total =ac*z;
    		document.getElementById('amount').value=total;
    		}
    	
    </script>
    </body>
    
    HTML:
     
    JohnnySchultz, Aug 23, 2011 IP
  3. bhandu

    bhandu Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Download Description Details Explanation Videos Need help to fix simple form- Download Description Details Explanation Videos Need help ...
     
    bhandu, Aug 24, 2011 IP