"Thank you for placing an order with us [customer name].
The cost of buying [quantity] of [product name] is [cost].
The discount for this purchase is [how much of a discount the customer will be receiving].
With the discount, your total order cost is [total cost of order with discount]."
Anything in brackets is a variable that I've defined in my code.
Here's the code:
Nothing after document.write("Thank you for placing an order with us, " + name + "."); works. I just cannot figure out what I've done wrong.
var name, product, price, discount, quantity;
var name = prompt("Welcome to Ryan's Ice Cream Shop. What is your name?","Enter name");
var sentence = "Hello " + name + " please look through our available products and services before placing your order.";
var product = prompt("Please enter the name of the product you are looking to purchase from the table.","Enter product");
var price = prompt("Please enter the price that corresponds to the product you would like to purchase from the price column.","Enter price");
var discount = prompt("Please enter the discount that corresponds to the product you would like to purchase from the discount column.","Enter discount");
var quantity = 1*prompt("How many " + product + " would you like to purchase?","Enter quantity");
var cost= price * quantity;
var orderdiscount= price * discount * quantity;
var totalcost= cost - orderdiscount;
document.write("Thank you for placing an order with us, " + name + ".");
document.write("The cost of buying " + quanitity + "of" + product + "is" + totalcost + ".");
document.write("The discount for this purchase is " + orderdiscount + ".");
document.write("With the discount, your total order cost is " + totalcost + ".");
Any help is greatly appreciated.
A quick check in the console reveals that quanitity is undefined. (Misspelling of quantity.)
The console is your friend! ;)
Use document.writeln(), like on this w3schools.com page !
But a form and the use of document.getElmentById (to insert the response in a paragraph) would be better...
Thanks guys I really appreciate it
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)