logo

URL query

Posted by Randy Inaneway in ASP

Tuesday, November 03, 2009 1:06:10 PM

I think I was able to query 2 values from 1 field but I can't remember how.

Example: field contains values 1, 2 , 3 for different records. I want to return 1 & 2 somthing like this:

pagename.asp?SWITCH=1

pagename.asp?SWITCH=2

that works fine but I want to return 1 AND 2

 

pagename.asp?SWITCH=1&2 does not work. It seems I did somthing like SWITCH=[1][2] or something similar some time ago and it worked but I just can't recall.

Is this possible or am I dreaming?

Thank you very much

 

 

 

 

 

 


Biography
Randy has not submitted biographical details.

Site Rank:  Not applicable - Current Winnings:  $0.00

Reply Reply Using Power Editor

re

Web star replied to Randy Inaneway

EggHeadCafe's human moderators scored this post for our messageboard contest.

Tuesday, November 03, 2009 11:00:14 PM

in URL passing querystring '&' use for seprate two different variables in url so u don't use 1&2

so u can wnat to get two value passing in query string then try this way

pagename.asp?SWITCH=1,2

and then u will split on comma(,) and get 1 and 2

or u can use this

 pass two value then use two different variable as follows

pagename.asp?SWITCH=1&SWITCH2=2


Biography
Web has not submitted biographical details.

Site Rank:  16th place - Current Winnings:  $0.00

Reply Reply Using Power Editor
[)ia6l0 iii

Couple of ways.

[)ia6l0 iii replied to Randy Inaneway

EggHeadCafe's human moderators scored this post for our messageboard contest.

Wednesday, November 04, 2009 12:31:29 AM

You would use the same variable name with your multi-values and create the url. However, a note of caution that there is a length limit to the querystring. Instead you would ideally use other ways of communicating between two asp web pages.

And also note that the Ampersand ("&") is used to separates parameters and not to concatenate them.

You can also give the values as comma separated and then use the indices to retrieve each one of them. But again, this is not adviced as it involved code change in the dependant file once the query string changes in your calling code.

If the param in the Querystring is called "myParam" and has the value "a, b, c"; to retrieve all of them you would write,
Response.Write Request.QueryString("myParam")
And to retrieve each one of them you would do ,
Response.Write Request.QueryString("myParam")(1) ' would give a
Response.Write Request.QueryString("myParam")(2) ' would give b
Response.Write Request.QueryString("myParam")(3)
' would give c

also not that in ASP, you could give the same name to the request querystring variables and still retrieve values.
Like the following example.
http://localhost/webfolder/page1.asp?param1=a&param1=b&param1=c

Response.Write Request.QueryString("param1")(1) ' would give a
Response.Write Request.QueryString("param1")(2)' would give b
Response.Write Request.QueryString("param1")(3)' would give c


Biography
:-)

Site Rank:  21th place - Current Winnings:  $0.00

Reply Reply Using Power Editor

asp

Jack jack replied to Randy Inaneway

Monday, November 09, 2009 2:09:28 AM

http://localhost/Website/page1.asp?n=1&n=2&n=3

for i=1 to Request.QueryString("n").Count
  Response.Write(Request.QueryString("n")(i) & "<br />")
next

It Will GIve
1
2
3


Biography
Jack has not submitted biographical details.

Site Rank:  Not applicable - Current Winnings:  $0.00

Reply Reply Using Power Editor
 

Didn't Find The Answer You Were Looking For?

EggHeadCafe has experts online right now that may know the answer to your question.  We pay them a bonus for answering as many questions as they can.  So, why not help them and yourself by becoming a member (free) and ask them your question right now?
Ask Question In Live Forum








  $1000    Adam Houldsworth - $173  |  Jonathan VH - $154  |  Kirtan Patel - $116  |  Mr. Khan - $99  |  F Cali - $94  |  more Neado  |  Free Icons  |  Privacy  |   (c) 2010