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

  • SEARCH
  • Home
  • 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 9172251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:18:02+00:00 2026-06-17T16:18:02+00:00

I have a page that sets a few variables using javascript Math.random() as shown.

  • 0

I have a page that sets a few variables using javascript Math.random() as shown.

var RandomValue1 = Math.floor(Math.random() * 5);
var RandomValue2 = Math.floor(Math.random() * 6);
var string = array1[RandomValue1];
var string = array2[RandomValue2];

I would like to allow a user to pass the RandomValue value through the URL to another person. When the second person goes to the shared URL, RandomValue is the value as the first person – so that the second person sees the same ‘string’ as the first person.

I am fairly new to web design and web programming so I don’t know if this needs to be handled on the server-side or client-side.

I assume I need to pass a url something like page1.html?RandomValue1=1&RandomValue2=3 but I cannot get the page to then set those variables and load. Can this be done in JavaScript?

  • 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-06-17T16:18:03+00:00Added an answer on June 17, 2026 at 4:18 pm

    You can read GET variables with javascript. Here is an example function (source):

    function getUrlVars() {
      var vars = {};
      var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
      });
      return vars;
    }
    

    Usage:

    var first = getUrlVars()["id"];
    var second = getUrlVars()["page"];
    
    alert(first);
    alert(second);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that I want to update non stop, every few seconds.
I have a page that I am using an Ajax Accordion and when I
I have a login page that sets a $_SESSION['usertype'] when I log in. I
I have a Wicket page class that sets the page title depending on the
I have a page that sets a session variable to hold a list of
I have a page that uses @font-face and I am playing with the JavaScript
I have a title bar on my web page that sets a message to
I have a project that sets up several pages with articles. Each page has,
I have a page that sets a cookie and then redirects the user to
I have a class that sets various session variables. After I set the session

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.