Я хочу знать, как я могу передать переменную с одной страницы на другую, используя JavaScript
Вот мой код:
var currentBasketPrice = 0;
var quotes = new Array(
"A good painting to me has always been like a friend. It keeps me company, comforts and inspires.",
"A man paints with his brains and not with his hands.",
"A picture is a poem without words.",
"A work of art is the unique result of a unique temperament.",
"An artist cannot fail; it is a success to be one.");
var quotePerson = new Array(
"Hedy Lamarr",
"Michaelangelo",
"Horace",
"Oscar Wilde",
"Charles Horton Cooley");
var imgSrc = new Array ("images/hangings/1.jpg","images/hangings/2.jpg");
var prices = new Array (100,50);
var sizes = new Array ("450*350","100*50");
var inBasketPrices = [];
var inBasketNames = [];
function load(displayQuotes, displayBasket, displayProductInfo)
{
if (displayQuotes==true)//quotes
{
var quotenum = Math.floor(Math.random()*5 );
document.getElementById('quote').innerHTML= quotes[quotenum];
document.getElementById('quoteperson').innerHTML=" - " + quotePerson[quotenum];
}
if(displayBasket==true)
{
var list = $('#basketsidebar ul');
list.append('<button type="button">Checkout</button>');
}
if(displayProductInfo==true)
{
for (var i = 0; i < prices.length; i++)
{
var list = $('#products ul');
list.append('<li><img src="'+imgSrc[i]+'" width="525px" height="350px"/></li>');
list.append('<li>Price: £' + prices[i] +'</li>');
list.append('<li>Size: ' + sizes[i] +'</li>');
list.append('<button type="button" onclick="addToBasket(' + i + ')">Add To Basket</button>');
}
}
}
function addToBasket(itemAdded)
{
inBasketPrices.push(prices[itemAdded]);
var list = $('#basketsidebar ul');
list.append('<li>Price: £' + inBasketPrices[itemAdded] +'</li>');
}
Я хочу сделать так, чтобы при нажатии кнопки оформления заказа пользователь направлялся на новую страницу, а элементы, находящиеся в настоящее время в корзине, переносились. На данный момент в корзину добавляются только цены товаров.
Я понятия не имею, как это сделать, поэтому, если кто-нибудь сможет помочь, это будет очень признательно.