Query strings are an excellent way to pass data between pages. This
tutorial will give you a basic understanding of using a query
string to send information to different page.
Lets look at the first part of this now. In the below example we will
pass various colors from this page to another. While this may not have
many practical implications, it will serve the purpose just as well.
Now then select a color below by clicking the appropriate link.
This will open a new window and display your color by making it the
background color of the page.
pop.asp is
the name of the page we are sending the info to. The question mark ?
in the link is what indicates there is a bit of info being passed. It
denotes that the query string we are sending is named color.
The equal sign =
indicates the the information being passed in the query string named
color is yellow.
Now let's view the source of pop.asp and see how it works.
First we REQUEST the QUERYSTRING named COLOR and dimension it as
clr.
<%
Dim clr
clr = Request.QueryString("color")
%>
<html>
<head>
Now in the title tag we use clr to title the page
<title>You picked <%=clr%></title>
</head>
In the body tag we use clr to set the background color.
<body bgcolor="<%=clr%>">
Finaly in the heading tag clr is used to write the color on the
page.
<h2>The color you selected was <%=clr%></h2>
</body>
</html>
Simple huh?
Learn how to use query strings in dealing with databases. You can
use them to ADD, DELETE,
or EDIT records in your tables.