Pass a variable to another html page

Go to the new location...

 

the code (not hard at all)

<A HREF = "getInformation.htm?myNewValue">Go to the new location...</a>

right there, on the link - send the new page's location, add a ? (that's the key) and then your value. That's it. -- on this page

 

now on my "getInformation" page:

<javascript>

var oldURL = new String()
oldURL = location.search

document.write("<CENTER><H2>")
document.write("Your variable sent: " + oldURL.substring(1, oldURL.length))
document.write("</CENTER></H2>")

</script>

 

Well, I'm using document.write - because I want to show you the value that is sent, so we'll skip that part.

I'm just going to deal with the information that was sent.

  1. Set up a variable to hold the link url that we sent this page - Here's a new concept - we tell our browser that our variable is going to be a string. -- This is how we "type" variables in javascript

    var oldURL = new String()

  2. Next, we set that variable to whatever url information we put in the last page we were on

    oldURL = location.search

  3. Now we use a string function on our parameter that we sent (because we told our browser that this was a string, so we could use those string functions...

    oldURL.substring(1, oldURL.length))

    hmmm....... I'm going to explain the substring method for strings in the string category (and it's a big one). - So, we'll revisit this part then.

    I just want you to be able to use this parameter passing from page to page, now.