Array values in query strings

Results 1 to 2 of 2

Thread: Array values in query strings

  1. #1
    Join Date
    Dec 1969

    Default Array values in query strings

    Does anyone know if it&#039s possible to append more than one value to a query string variable. Like if I have three ids of the same kind that I want to pass to the next page, I want to be able to pass that in the querystring as one variable possibly delimited by some character. <BR><BR>Example:<BR><BR>Any array holding three (or less or more) values<BR>id(0) = A<BR>id(1) = B<BR>id(2) = C<BR><BR>Can you do something like redirect to <BR>nextpage.asp?id=A+B+C<BR><BR>Any good references to help with query string would be great, too! Thank you. <BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Array values in query strings

    Proper way:<BR><BR>nextpage.asp?id=A&id=B&id=C<BR><BR>In your ASP page, you can then get *all* the values via:<BR><BR>&#060;%<BR>strValues = Request.QueryString("id")<BR>&#039 and turn that into an array:<BR>valuesArray = Split( strValues, ", " )<BR>%&#062;<BR><BR>[Doesn&#039t work if any of the separate values contain a comma. There is a workaround. If that matters, ask.]<BR><BR>Remember that A, B, and C can NOT contain any of the "poison" characters for URLs. You need to encode them to be safe.<BR><BR>But why use a querystring in the first place? *SO* much more preferable to use METHOD=POST and put the values in, perhaps, hidden form fields.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts