Passing a name=value pair
OK, I think this must be fairly easy (when you know how). All I want to do is, when a user clicks on a hyperlink on a page have a name=value pair (or even just a value) passed to the new page and be able to read it in to a variable at the other end. I'm happy to use VBscript.
Thanks
Mark Hensler posted this at 06:20 — 19th October 2001.
He has: 4,048 posts
Joined: Aug 2000
Is the variable to be used server-side (using ASP) or client-side on the second page?
PaulCAust posted this at 06:23 — 19th October 2001.
They have: 25 posts
Joined: Aug 2001
on a second HTML page, client side. It is about 5:00pm friday here so i'm going for a beer. Thanks everyone and have a good weekend. Looking forward to hearing how to do this.
Mark Hensler posted this at 07:58 — 19th October 2001.
He has: 4,048 posts
Joined: Aug 2000
You'll be passing the info like this:
page2.html?my_var=my_value
I've not used much VBScript client side. Mainly because I think it's only suppored by IE (not Netscape).
Using ASP (written in VBScript), the code to retreive the var would be:
my_var = Request.QueryString("my_var")
'my_var' will be given the value of whatever was opposite the equal sign in the querystring, and you can use it elsewhere in your script.
It's about 1AM here. So, I'm making my last rounds before I go to bed.
Mark Hensler
If there is no answer on Google, then there is no question.
Vincent Puglia posted this at 10:35 — 19th October 2001.
They have: 634 posts
Joined: Dec 1999
Hi,
var page2Arg = location.search.substr(1).split("=")
produces the following array:
page2Arg[0] = var
page2Arg[1] = value
location.search.substr(1) produces a string beginning with first char after the "?"
4 hours sleep and going for a 6 hour drive.
Vinny
Where the world once stood
the blades of grass cut me still
Mark Hensler posted this at 15:45 — 19th October 2001.
He has: 4,048 posts
Joined: Aug 2000
Vinny... remember..
"Stay between the lines. The lines are our friends."
You should maybe get someone else to drive.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.