One of the most common requests That
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:
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 window.location.search 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:
- The location.search property
- Popup windows
- Frames, and even framesets
Location.search
Have you ever seen a web address like this: "http://mysite.com/mydirectory/mycgi.cgi?adfjwa4n=yes" ? 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 window.location.search 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 window.location.search 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:
<HTML> <HEAD> <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+ "'&MyTest.value='"+document.forms.myForm.MyTest.value+"'" } //--> </SCRIPT> </HEAD> <BODY> <FORM NAME="myForm"> <INPUT TYPE="TEXT" NAME="MyValue" SIZE="5" VALUE="AEIOU"> <INPUT TYPE="BUTTON" onClick="nextpage()" VALUE="Go to the next page"> </FORM> </BODY> </HTML>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.
0 comments:
Post a Comment