Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7166723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:27:34+00:00 2026-05-28T14:27:34+00:00

I want to know how I can pass a variable from one page to

  • 0

I want to know how I can pass a variable from one page to another using JavaScript

Here’s my code:

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>');
}

I want to make it so that when the checkout button is clicked the user is directed to a new page, and the items currently in the basket are carried over. At the moment only the prices of the items get added to the basket.

I have no idea how to do this so if anyone could help it would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:27:35+00:00Added an answer on May 28, 2026 at 2:27 pm

    Javascript is a language that gets executed by your browser on a defined page.
    The relation between pages is handled by the HTTP protocol, and thus propagating data from one page another should be done with this protocol.

    HTTP allows you to share data in three ways:

    1. GET
    2. POST
    3. Cookies

    Data in the GET format is easy to write in Javascript, you only have to append ?var1=value&var2=value2 to your URL. You can retrieve data by either using a server-side programming language or by analyzing the URL (see here). POST can be a little more tricky for your application, but can still be done. Cookies can also be an option, but are a bit different. Instead of following the HTTP request as GET/POST, Cookies are being held on the client computer. You can manipulate cookies via Javascript as shown in this tutorial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i just want to know can we pass nsdata or array datatype from one
In Visual Studio Debug part, we can pass arguments. I want to know how
I want to know I can dynamically modify an existing Crystal Report (using C#
I want to know how can I perform VS2008 load test from five different
I want to know how can I read attachment messages without using scriplets in
I'm using Tomcat 6.0, and I want to know how can I configure Tomcat's
I want to know how to pass variables from a form to a php
I here want to call another website url, login into it, and use one
Can I pass a string from Java to my C++ routine using JNI function
I want to know how can we know the other users of Oracle 10g

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.