Skip to content

Instantly share code, notes, and snippets.

@jwax
Created November 10, 2011 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jwax/1355443 to your computer and use it in GitHub Desktop.
Save jwax/1355443 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>JavaScript Assignment 3: Jonathan Waxman</title>
</head>
<body> <table border="1" width="100%" height="550"> <tr> <th colspan="2" bgcolor="navy" style="color:white"><h1>JW's Electronic Post - eCommerce</h1></th> </tr> <tr> <td bgcolor="navy" width=5%><a href="home.html"> <font color="white">Home</font></a> <br/><a href="pressrelease.html"> <font color="white">Press Release</font></a> <br/><a href="products.html"><font color="white">Products</font></a> </td> <td> <table border="1" width="100%" height="500"> <tr> <td height="75" cellpadding="30" align="center" style="color:navy"> <h3>Products</h3></td> <td height="75" cellpadding="30" align="center" style="color:navy"> <h3>Prices</h3> </td> <td height="75" cellpadding="30" align="center" style="color:navy"> <h3>Discounts</h3></td> </tr> </td> </tr> <tr align="center" style="color:navy"> <td> <a href="http://www.sennheiserusa.com/around-ear-headphones-acoustic_504631" target="_blank"><font color="navy">Sennheiser HD 558</font></a></td><td>Price: $147.87</td><td>.10</td></tr><tr align="center" style="color:navy"><td> <a href="http://www.sennheiserusa.com/over-ear-headphones-acoustic-headphones_504633" target="_blank"><font color="navy">Sennheiser HD 598</font></a></td><td>Price: $249.95</td><td>.10</td></tr><tr align="center" style="color:navy"><td> <a href="http://www.sennheiserusa.com/over-ear-headphones-highest-quality-headphones_004465" target="_blank"><font color="navy">Sennheiser HD 600</font></a></td><td> Price: $314.95</td><td>.10</td></tr><tr align="center" style="color:navy"><td> <a href="http://www.sennheiserusa.com/high-quality-headphones-around-ear_009969" target="_blank"><font color="navy">Sennheiser HD 650</font></a></td><td>Price: $359.17</td><td>.10</td></tr>
</table> <tr>
<td colspan="2" bgcolor="navy" style="color:white"><b><p align="center"><a href="mailto:jwaxman@eden.rutgers.edu"> <font color="white"> Email Us! </font></a> <br/> <br/>732-555-3456 <br/>53 Bumble Avenue <br/>East Bumble, NJ 99813</p></b> </td>
</tr> </table>
<script type="text/javascript">
/* Jonathan Waxman
TA: Bandhan
JavaScript 3
Due: November 4th */
var customername = prompt("Welcome to JW's Electronic Post. Please enter your name","");
alert("Hello " +customername + ". Please look through our available products and services before placing your order.");
var product = prompt("What product are you ordering?","");
var quantity = 1*prompt("How many " +product + "'s would you like to order?","");
var confirmation= confirm (customername + " you ordered "+ quantity + " " + product + ". Is this correct?");
var discount=0.10;
var cost_of_order;
var discountoff;
var discounttotal;
var hd558price = 147.87;
var hd598price = 249.95;
var hd600price = 314.95;
var hd650price = 359.17;
var runningtotal = 0;
var ordermore = confirm(customername + ", would you like to order another product?");
var price_of_product;
var running_total
do
{
product = prompt("What product are you ordering?","");
quantity = 1*prompt("How many " +product + "'s would you like to order?","");
if (product=="sennheiser hd 558")
{
cost_of_order=(hd558price*quantity);
discountoff=(hd558price*discount*quantity);
discounttotal=(cost_of_order-discountoff);
document.write("Thank you for placing an order with us, <b>" + customername + "</b>.<br/>");
document.write("The cost of buying <b>" + quantity + "</b> of <b>" + product +"</b> is $<b>" + cost_of_order +"</b>. <br />");
document.write("The discount for this purchase is $<b>" + discountoff + "</b>. <br/>");
document.write("With the discount, your total of your order is $<b>" + discounttotal + "</b>.");
}
else if (product=="sennheiser hd 598")
{
cost_of_order=(hd598price*quantity);
discountoff=(hd598price*discount*quantity);
discounttotal=(cost_of_order-discountoff);
document.write("Thank you for placing an order with us, <b>" + customername + "</b>.<br/>");
document.write("The cost of buying <b>" + quantity + "</b> of <b>" + product +"</b> is $<b>" + cost_of_order +"</b>. <br />");
document.write("The discount for this purchase is $<b>" + discountoff + "</b>. <br/>");
document.write("With the discount, your total of your order is $<b>" + discounttotal + "</b>.");
}
else if (product=="sennheiser hd 600")
{
cost_of_order=(hd600price*quantity);
discountoff=(hd600price*discount*quantity);
discounttotal=(cost_of_order-discountoff);
document.write("Thank you for placing an order with us, <b>" + customername + "</b>.<br/>");
document.write("The cost of buying <b>" + quantity + "</b> of <b>" + product +"</b> is $<b>" + cost_of_order +"</b>. <br />");
document.write("The discount for this purchase is $<b>" + discountoff + "</b>. <br/>");
document.write("With the discount, your total of your order is $<b>" + discounttotal + "</b>.");
}
else if (product=="sennheiser hd 650")
{
cost_of_order=(hd650price*quantity);
discountoff=(hd650price*discount*quantity);
discounttotal=(cost_of_order-discountoff);
document.write("Thank you for placing an order with us, <b>" + customername + "</b>.<br/>");
document.write("The cost of buying <b>" + quantity + "</b> of <b>" + product +"</b> is $<b>" + cost_of_order +"</b>. <br />");
document.write("The discount for this purchase is $<b>" + discountoff + "</b>. <br/>");
document.write("With the discount, your total of your order is $<b>" + discounttotal + "</b>.");
}
else
{
alert("Sorry, " + customername + ". You entered an invalid product. We will not include this in your order.");
product=false;
discounttotal=0;
}
ordermore = confirm(customername + ", would you like to order another product?");
running_total=(runningtotal+discounttotal);
}
while (ordermore==true);
document.write("<br>" + "Thank you for placing an order with us, " + customername + "." + "<br>");
document.write("The total order cost is "+running_total+".");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment