Web Analytics Made Easy -
StatCounter Need help to fix simple form - CodingForum

Announcement

Collapse
No announcement yet.

Need help to fix simple form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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="[email protected]"><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
    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="[email protected]"><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>

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎