Passing values to another page

R

Rob

I have a web page consisting of multiple images which
under each is a button. When each button is clicked I want
to navigate to one page on which is displayed the image
name along with other information.
This requires the passing of values/variables/parameters
from the first page to the second, and the second page
displaying this variable information based on the image
selected.
Is there an easy way to pass this information to the
second page via the hyperlink?
 
J

Jim Buyens

-----Original Message-----
I have a web page consisting of multiple images which
under each is a button. When each button is clicked I
want to navigate to one page on which is displayed the
image name along with other information.
This requires the passing of values/variables/parameters
from the first page to the second, and the second page
displaying this variable information based on the image
selected.
Is there an easy way to pass this information to the
second page via the hyperlink?

Yes.

First, for each item of information, append a query string
variable to the URL. Here's an example?

<a href="aboutpic.htm?device=Claw+Hammer&date=1/1/2003">
<img ...></a>

The question mark begins the query string; each variable
has a name=value pair, and ampersands separate name=value
pairs. Note that you must URLencode any names or values
you use; for example, you must use +'s instead of spaces
and hex combinations like %22 for the " character.

If the target page is an asp or aspx page, you can
retrieve these values from the Request.QueryString
collection. Given the above URL, for example,
Request.QueryString("device") would equal Claw Hammer.

In an ordinary HTML page, add this script to the <head>
section of your page.

<script>
function qsobj (){
var qvbl;
var qstring = "" + document.location.search.substring(1);
if (qstring != ""){
var qpairs = qstring.split("&");
for (i=0; i < qpairs.length; i++) {
qvbl = qpairs.split("=");
this["" + qvbl[0]] = unescape(qvbl[1].replace
("+"," "));
}
}
}
var qstr = new qsobj();
</script>

Then, add statements like the following to display a
specific value:

<script>document.write(qstr.device);</script>

Jim Buyens
Microsoft FrontPage MVP
(e-mail address removed)
http://www.interlacken.com
Author of:
*------------------------------------------------------*
|\----------------------------------------------------/|
|| Microsoft Office FrontPage 2003 Inside Out ||
|| Microsoft FrontPage Version 2002 Inside Out ||
|| Web Database Development Step by Step .NET Edition ||
|| Troubleshooting Microsoft FrontPage 2002 ||
|| Faster Smarter Beginning Programming ||
|| (All from Microsoft Press) ||
|/----------------------------------------------------\|
*------------------------------------------------------*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top