I asked a similar question earlier, but realized later that I NEED to use javascript for this bit. Here's my situation:
I have a shopping website, with product x and a "Buy" button. The "Buy" button links to the checkout page, as well as a javascript function that has 2 global variables called "product" and "price". I want to display these 2 variables on the checkout page which will auto-update depending on which products "Buy" button the user presses.
var x = "iPhone";
var xprice = 199.99;
var product;
var price;
function productX(){
product = x;
price = xprice;
}
^^^^ Does not work. It will simply relay "undefined" in the area the variable is written. Can someone help me out, if they can understand what I'm trying to do?
I simply want the confirmation page to show the product the person is going to buy, and the price depending on which buy button the user pressed. I cannot seem to get it to work using JavaScript. I don't want to use PHP, databases or cookies.
Thank You