Forum Moderators: open

Message Too Old, No Replies

Receiving variables in javascript

Javascript,variables

         

sanblasena

7:43 pm on Feb 22, 2003 (gmt 0)

10+ Year Member



Hello, I am passing a variable to another html screen. It is coming in like this:?item=1 I want to use this as an index in Javascript. How do I access this variable in Javascript? Also, what is the official name for this type of passed variable. Since I didn't know what they were called I couldn't look it up. Thanks in advance for your help. Pat

Xoc

6:05 am on Feb 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Anything after the? is called the "Query String" or "querystring". Search on both.

I believe that you can parse the location.href variable in JavaScript. I don't know if there is another way.

Avellar

4:08 pm on Feb 26, 2003 (gmt 0)

10+ Year Member



Another answer is to pick up the variable in VBScript and response.write the entire javascript. Something like:

<%

dim item

item = request("item")

response.write "<script language=JavaScript>"
response.write "Var itm = " & item
response.write "</script>"

Avellar

4:10 pm on Feb 26, 2003 (gmt 0)

10+ Year Member



you might have to play around with that above a bit, maybe some type conversion or something. But the concept should work.

RossWal

12:56 am on Feb 28, 2003 (gmt 0)

10+ Year Member



Good solution Avellar. I do that quite a bit. I did notice a typo in "Var" though. I think it's lower case.

Ross