Reputation: 8727
I have this form with a select list box in it. It shows a total that will change when the user selects different options:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paypal">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="business" value="[email protected]">
<select name="handling_cart" onChange="refresh();" style="margin-bottom: 5px;">
<option selected value="10.00">UK £10.00</option>
<option value="30.00">France £30.00</option>
<option value="35.00">Germany £35.00</option>
</select>
</td>
</tr>
<tr>
<td>Grand Total:</td>
<td>£
<script lanuage="JavaScript">
var delivery = document.paypal.handling_cart.value;
var total = parseInt(jtotal)+parseInt(delivery);
document.write(total);
</script></td>
</tr>
I haven't got a function refresh() but I'm guessing I'm going to need one?
TIA
Upvotes: 0
Views: 7674
Reputation: 12503
Okay, created refresh() for you. Working demo is here http://jsfiddle.net/hwwDj/3/
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paypal">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="business" value="[email protected]">
<select name="handling_cart" onChange="refresh();" style="margin-bottom: 5px;">
<option selected value="10.00">UK £10.00</option>
<option value="30.00">France £30.00</option>
<option value="35.00">Germany £35.00</option>
</select>
</td>
</tr>
<tr>
<td>Grand Total:</td>
<td><div id="etd">£</div></td>
</tr>
<script lanuage="javascript">
var jtotal=10;
var delivery = document.paypal.handling_cart.value;
function refresh()
{
delivery = document.paypal.handling_cart.value;
var total = parseInt(jtotal)+parseInt(delivery);
document.getElementById("etd").innerHTML="£ "+total;
}
//document.write(total);
</script>
Upvotes: 2