Sending objects from one page to another

Credits: This tutorial is written (except for current page) and contributed by Alex Vincent. Edited by JavaScript Kit. Alex is a long time visitor of JavaScript Kit, and participant of the JK Help Forum.

    One of the most common requests we get in the JavaScript Kit forum is "How do I send a variable to the next page?"  In this tutorial, we're going to give you several examples of doing precisely this. Specifically, we're going to cover:

Have you ever seen a web address like this: "" ?  This, when loaded into a window, fills the window.location object with several components.  This object has many properties -- and one of the properties most underused in JavaScripting is the object.

This object, simply put, is a string which holds everything following the question mark in a page (including that question mark.)  For instance, with the above URL, the property would have the value "?adfjwa4n=yes".  How can you use this information?

First, you need to send the information.  Here's some sample code:

<SCRIPT Language="JavaScript">
function nextpage() {
// I want to send on the MyValue element of the form below.
window.location.href = "send2.htm?MyValue.value='"+document.forms.myForm.MyValue.value+

<FORM NAME="myForm">
<INPUT TYPE="BUTTON" onClick="nextpage()" VALUE="Go to the next page">

Try it out here. You can change the text to whatever you want, and it will show up as you typed it in the next page.