title: Paypal add to cart multiple items form with discount
body: <p>I'm trying to offer a discount based on the purchase amount of the buyer using a paypal Add to Cart form. Basically I'm giving out for discount codes Disc1, Disc2, Disc3, Disc4, which will discount $5, $10, $20, $50. But each can work only if the purchase amount exceeds the $25, $50, $100, $250 respectively. </p>
  
  <p>I'm trying to do this by calling a Javascript file which will apply the discount if the minimum price conditions are met.</p>
  
  <p>The PROBLEM is that the form is for multiple items. So the variable for "amount" is not there, but there's different amounts for each option, so option_amount0, option_amount1, option_amount2.... etc. I can make the code work if there was one "amount", but not like here with multiple items/prices. </p>
  
  <p>The HTML code looks like this: </p>
  
  <pre><code>    &lt;head&gt;
  &lt;script language="JavaScript" type="text/javascript" src="coupon.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
          &lt;form target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt;
      &lt;input type="hidden" name="cmd" value="_cart"&gt;
      &lt;input type="hidden" name="business" value="email@email.com"&gt;
      &lt;input type="hidden" name="lc" value="US"&gt;
      &lt;input type="hidden" name="item_name" value="Products"&gt;
      &lt;input type="hidden" name="button_subtype" value=""&gt;
      &lt;input type="hidden" name="no_shipping" value="1"&gt;
      &lt;input type="hidden" name="undefined_quantity" value="1"&gt;
      &lt;input type="hidden" name="rm" value="1"&gt;
      &lt;input type="hidden" name="return" value="www.website.com"&gt;
      &lt;input type="hidden" name="cancel_return" value="www.website.com"&gt;
      &lt;input type="hidden" name="currency_code" value="USD"&gt;
      &lt;input type="hidden" name="tax_rate" value="0.000"&gt;
      &lt;input type="hidden" name="shipping" value="0.00"&gt;
      &lt;input type="hidden" name="add" value="1"&gt;
      &lt;input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted"&gt;
      &lt;table&gt;
      &lt;tr&gt;&lt;td&gt;&lt;br /&gt;&lt;h4&gt;
      &lt;center&gt;&lt;input type="hidden" name="on0" value="Products"&gt;Choose a Product&lt;/center&gt;&lt;/h4&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;center&gt;
      &lt;select name="os0" style="width: 230px"&gt;&lt;/center&gt;
          &lt;option value="item1"&gt;Product 1 : $15&lt;/option&gt;
              &lt;option value="item2"&gt;Product 2 : $25&lt;/option&gt;
          &lt;option value="item3"&gt;Product 3 : $75&lt;/option&gt;
          &lt;option value="item4"&gt;Product 4 : $150&lt;/option&gt;
          &lt;option value="item5"&gt;Product 5 : $300&lt;/option&gt;
  
      &lt;/select&gt; &lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
      &lt;input type="hidden" name="currency_code" value="USD"&gt;
  
      &lt;input type="hidden" name="option_select0" value="item1"&gt;
      &lt;input type="hidden" name="option_amount0" value="15.00"&gt;
      &lt;input type="hidden" name="option_select1" value="item2"&gt;
      &lt;input type="hidden" name="option_amount1" value="25.00"&gt;
      &lt;input type="hidden" name="option_select2" value="item3"&gt;
      &lt;input type="hidden" name="option_amount2" value="75.00"&gt;
      &lt;input type="hidden" name="option_select3" value="item4"&gt;
      &lt;input type="hidden" name="option_amount3" value="150.00"&gt;
      &lt;input type="hidden" name="option_select4" value="item4"&gt;
      &lt;input type="hidden" name="option_amount4" value="300.00"&gt;
      &lt;input type="hidden" name="option_index" value="0"&gt;
  
  
      &lt;input type="hidden" name="discount_amount"&gt;
  
      &lt;br /&gt;
      &lt;!--  Enter Coupon  --&gt; 
      &lt;center&gt;Coupon Code:&lt;/span&gt; &lt;br /&gt;
      &lt;input type="text" name="text1" /&gt; &lt;/center&gt;
      &lt;br /&gt;
      &lt;!--  End Coupon  --&gt; 
  
      &lt;input type="image" src="images/btn_cart.gif" border="0" onclick=CalculateOrder(this.form) name="submit" alt="PayPal - The safer, easier way to pay online!"&gt;
      &lt;img alt="" border="0" src="images/btn_cart.gif" width="1" height="1"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>The Javascript file is: </p>
  
  <pre><code>var coup1="Disc1";
  var coup2="Disc2";
  var coup3="Disc3";
  var coup4="Disc4";
  
  
  
  function CalculateOrder(form) {
  
  if (form.text1.value == coup1 &amp;&amp; ((form.option_amount.value&gt;=25)))
  
  {
  
  form.discount_amount.value = "5";
  
  }
  
  if (form.text1.value == coup2 &amp;&amp; ((form.option_amount.value&gt;=50)))
  
  {
  
  form.discount_amount.value = "10";
  
  }
  
  
  
  if (form.text1.value == coup3 &amp;&amp; ((form.option_amount.value&gt;=100)))
  
  {
  
  form.discount_amount.value = "20";
  
  }
  
  
  if (form.text1.value == coup4) &amp;&amp; ((form.option_amount.value&gt;=250)))
  
  {
  
  form.discount_amount.value = "50";
  
  }
  
  }
  </code></pre>
  
  <p>How can I make the script account for the option_amount from the HTML form? 
  Any help would be greatly appreciated! </p>