Need Help Debugging Html Javascript?

Everything works perfectly fine up until the lines I isolated out with asteriks.

var name=””;
var name_of_product=””;
var price_of_product=0;
var item_discount=0;
var quantity_required=0;
var cost_of_order=0;
var discount=0;
name = prompt(“Welcome to K&K Tours, Inc. Please enter your name:”,””);
alert(“Hello, ” + name + “! Take a second to look at our new products discounted for limited time only!”);
name_of_product = prompt(“What would you like to purchase?”,””);
price_of_product=prompt(“What is the price of “+name_of_product+”?”,””);
item_discount=prompt(“What is the discount decimal?”,””);
quantity_required=prompt(“How many “+name_of_product+” would you like?”,””);
cost_of_order=price_of_product*quanti…
discount=price_of_product*item_discou…
document.write(“Thank you for placing an order with us, “+name);
**************************************…
document.write(“The total cost of ” + quantity_required + ” of ” + name_of_product + ” is ” +cost_of_order”.”);
document.write(“Total discount: “+discount);
document.write(“Total price after discount is: “+(cost_of_order-discount));

I debugged line by line and it seems the script stops working when the last three lines of code are there.
Thanks for help.

Both comments and pings are currently closed.

2 Responses to “Need Help Debugging Html Javascript?”

  1. Ani says:

    You just forgot to add a + here:
    document.write(“The total cost of ” + quantity_required + ” of ” + name_of_product + ” is ” +cost_of_order+”.”);
    Between cost_of_order and “.”
    @Fred: He never told you what he is making. My guess is that it’s just a simple calculator that lets the user plugin whichever value they wish.

  2. Fred says:

    Sorry but the whole thing is wrong. How on earth can you sell anything when the customer has to type in what they want, then type in the price, then the quantity. You should be showing them a list of products and the system should have the price of that item stored. You also have absolutely no discount system set up. and for that kind of work your do NOT use javascript, you use php with a mysql database to maintain the records of products, prices, discounts and sales. Otherwise a customer can order horse manure, for which I am sure you have no idea what the price should be and where to get it if they want 22000 tons of it. Or they can order sdfcdosemjggv. Work that out if you can.They could also order a house and enter a price of $10.00. Are you going to supply that?

Powered by WordPress | Designed by: free css template | Thanks to hostgator coupon and web hosting reviews