ASDV-WebDev/Semester 1/Assignments/JavaScript/ch03/ex_3_7.html

33 lines
872 B
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Example 3.7</title>
<script>
function shipCost()
{
var price = parseInt(prompt("What is your merchandise total?"," "));
if (price > 1.00 && price < 25.00)
var ship = 5.00;
if (price >= 25.00 && price < 50.00)
var ship = 7.00;
if (price >= 50.00 && price < 75.00)
var ship = 9.00;
if (price >= 75.00 && price < 100.00)
var ship = 10.00;
if (price >= 100.00)
var ship = 0.00;
document.write("<p>Your shipping cost will be $ " + ship + ".</p>");
}
</script>
</<head>
<body>
<table align ="center" width ="70%"><tr><td>
<h1>&nbsp;</h2>
<h1>Calculating Shipping Costs</h1>
<h3>Click the button to calculate your shipping cost</h3>
<p><input type="button" id="ship" value="calculate your shipping charge" onclick="shipCost();" /></p>
</td></tr></table></body>
</html>