Hey all. I sell my artwork online and I want to be able to accept coupon codes. I haven't gone the shopping cart route but have hacked some paypal code to take orders. On the paypal developer forum there is some javascript code that will take a coupon codes according to my defined arrays. It would be fine if my product came in one size and price but I have multiple sizes and prices accordingly. I have some basic js code that I would like to alter according to an html jump/select menu. The user selects the size and price and then inputs the coupon code which discounts the price accordingly.

The js asks me to set baseamt. I would like the select menu to alter that variable instead of actually putting it in the js file. Here is the js:

var discnt = 0; // no default percent discount

var coupons = new Array ( // place to put coupon codes
"acdc", // 1st coupon value - comma seperated
"superman", // 2nd coupon value - add all you want
"nightrider" // 3rd coupon value
var coupdc = new Array ( // place to put discounts for coupon vals
var coupval = "(blanket)"; // what user entered as coupon code

function ChkCoup () { // check user coupon entry
var i;
discnt = 0; // assume the worst
for (i=0; i<coupons.length; i++) {
if (coupval == coupons[i]) {
discnt = coupdc[i]; // remember the discount amt
alert ("Valid coupon number! \n\n" + discnt +
"% discount now in effect.");
alert ("'" + coupval + "' is not a valid code!");

function Dollar (val) { // force to valid dollar amount
var str,pos,rnd=0;
if (val < .995) rnd = 1; // for old Netscape browsers
str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape
pos = str.indexOf (".");
if (pos > 0) str = str.substring (rnd, pos + 3);
return str;

function ReadForm (obj1) { // apply the discount
var amt,des;
amt = obj1.baseamt.value*1.0; // base amount
des = obj1.basedes.value; // base description

if (discnt > 0) { // only if discount is active
amt = Dollar (amt - (amt * discnt/100.0));
des = des + ", " + discnt + "% dis, COUP = " + coupval;

obj1.amount.value = Dollar (amt);
obj1.item_name.value = des;

Here is the html that works with one item and price:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="this.target = 'paypal';
return ReadForm (this);">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="blah@blahblah.com" />
<input type="hidden" name="item_name" value="<txp:title />" />
<input type="hidden" name="amount" value="50.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="baseamt" value="50.00" />
<input type="hidden" name="basedes" value="<txp:title />" />
<h1>Enter a Coupon Code if you have one</h1>
<p><input type="text" size="14" name="coupcode" /><input type="button" value="Verify/Apply"
onclick="coupval = this.form.coupcode.value;
ChkCoup();" /></p>
<h1>Add to Cart</h1>
<p><input type="submit" name="submit" alt="cart add" value="add / buy" />
<input type="submit" name="display" value="View Cart" /></p>

Here is the select menu that I would like to integrate:
<form class="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="paypal">
<input type="hidden" name="add" value="1" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="business" value="blah@blahblah.com" />
<input type="hidden" name="item_name" value="<txp:title />" />
<input type="hidden" name="amount" value="" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<select name="amount">
<option>Choose Print Type and Size</option>
<option value="50.00">(8 &frac12; x 11 Print) $50</option>
<option value="160.00">(13 x 19 Print) $160</option>
<input type="submit" name="submit" value="Add / Buy" />
<input type="submit" name="display" value="View Cart" />

Any help appreciated.