There are many times it might be necessary to pass a variable between two pages. If one wanted to perform a DHTML version of a server-side page generator (index.asp?page=home.html) or just wanted to be able to fill in forms with default values, one needs to be able to pass variables between pages. This tutorial focuses on the GET method (the stuff after the ? at the end of the URL).
Cons: This method does NOT hide variables from the user! The user is able to see all variables and their values in the location box at the top of their screen.
1. How do I append stuff to the URL? There are more than one ways to append "stuff" to the URL. The method depends on the way you want variables to be passed.
If the next page is accessed through a link, then the <a> tag can be used alone. <a href="redirect.html?page=1">Page 1</a> <a href="redirect.html?page=2">Page 2</a> <a href="redirect.html?page=3">Page 3</a> etc.
The other way is through form values. For your form tag: <form name="tform" action="redirect.html" method="get"> <select name="page"> <option value="1" selected="selected">Page 1</option> <option value="2">Page 2</option> <option value="3">Page 3</option> </select><br> <input type="submit" value="Go!"> </form>
For this tutorial, I will use a simple name page, one with a field to enter the name, another with a page to display it. However, this method will work for as many variables as necessary, as long as the maximum length of the URL is not passed.