Passing a name=value pair

They have: 25 posts

Joined: Aug 2001

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's picture

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?

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. Cheers!

Mark Hensler's picture

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's picture

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's picture

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.