Hi,
I'm making an online store and want each product to have options. When the user clicks a drop down box the cost of that option will be added to the base price of the product. I decided to do this using javascript and calculating the price works fine.
However, how would I get this new total price for the product (E.g. if i select Retail Package from the list, I would need to pass the value of £667.57 using asp) using asp?
The source code is below, or you can view the page directly here.
Thanks
I'm making an online store and want each product to have options. When the user clicks a drop down box the cost of that option will be added to the base price of the product. I decided to do this using javascript and calculating the price works fine.
However, how would I get this new total price for the product (E.g. if i select Retail Package from the list, I would need to pass the value of £667.57 using asp) using asp?
The source code is below, or you can view the page directly here.
Thanks
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/javascript">
function yadada(id, VATRate) {
var BasePrice =document.getElementById("OriginalPrice");
var theBasePrice = Number(BasePrice.value).toFixed(2);
//alert("Base Price £" + theBasePrice)
var OptionPrice = document.getElementById(id);
var theOptionPrice = Number(OptionPrice.options[OptionPrice.selectedIndex].value).toFixed(2);
//alert("Opt Price £" + theOptionPrice)
var AmendedPrice = Number(theOptionPrice) + Number(theBasePrice);
var AmendedPriceInc = Number(AmendedPrice) * (1+(VATRate/100));
document.getElementById("prodprice").innerHTML="£"+AmendedPrice.toFixed(2);
document.getElementById("prodpricevat").innerHTML="£"+AmendedPriceInc.toFixed(2);
}
</script>
</head>
<body style="font-family: Tahoma; font-size:10pt;width: 500px;">
<div>
<strong>Windows Vista Super Ultimate OEM (£500.00)</strong><br />
If you use the same computer at home and for your daily work, Windows Vista Ultimate is an excellent choice. You can
smoothly shift between the things you want to do and the things you need to do. For fun, you'll love the extensive
options you get for music, images, live and recorded TV, and online entertainment. For work, you'll
find improved document sharing and networking support.
<!--ids, titles and values would Be Generated Automatically via a database query-->
<p style="font-weight:bold;" id="optionchoice">Options:</p>
<input type="hidden" id="OriginalPrice" name="OriginalPrice" value="500.00">
<select id="ProductOptions" name="ProductOptions" onchange="yadada(this.id,15);" style="font:Georgia;font-size:12px;width: 330px;">
<option id="GiftedWrapped" title="Gift Wrapped£51.50" value="51.50">Gifted Wrapped Option (£51.50)</option>
<option id="Retail" title="Retail£80.50" value="80.50">Retail Package Option (£80.50)</option>
</select>
<input type="hidden" id="OriginalPriceVAT" name="OriginalPriceVAT" value="">
<br /><br />
<span id="prodprice">£500.00</span>
<span class="priceLrg"> ex VAT</span><br />
<span id="prodpricevat" style="color:#FF0000;">£575.00</span> <br /><br />
</div>
</body>
</html>