Asp Removing Single Item From Query String

ASP removing single item from query stri

Page 1 of 1

2 Replies - 11569 Views - Last Post: 15 August 2003 - 09:00 AM Rate Topic: -----

#1 poab  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-June 02

Asp Removing Single Item From Query String

Posted 15 August 2003 - 05:29 AM

Hi,

I have a tiny problem. If I use the following asp script (It's a bit rough I wrote it myself) then I can create links that when you click on them the page is refreshed and the information clicked for is reveled:

<a href="<% Request.ServerVariables(SCRIPT_NAME) %><% if Request.QueryString("open") = "ec" then %>"<% else %>?open=ec"<% end if %> />My ec link</a><% if Request.QueryString("open") = "ec" then %><!-- paragraph goes here --><% End If %> 
'next 
<a href="<% Request.ServerVariables(SCRIPT_NAME) %><% if Request.QueryString("open") = "ed" then %>"<% else %>?open=ed"<% end if %> />My ed link</a><% if Request.QueryString("open") = "ed" then %><!-- paragraph goes here --><% End If %>



That works fine. Click one it 'opens', click another the first 'closes' and the new link clicked 'opens'. Basically it works by having the content there, or not there depending on the query string.

I would like to increase the functionality. By changin what's added to the query string so that the parameter isn't the constant, adding an ampersand and appending to the query string the existing query string I can open more than one piece of information at once, using this script:

<a href="<% Request.ServerVariables(SCRIPT_NAME) %><% if Request.QueryString("ec") = "open" then %>"<% else %>?<% Response.write(Request.QueryString) %>ec=open&"<% end if %> />My ec link</a><% if Request.QueryString("ec") = "open" then %><!-- paragraph goes here --><% End If %> 
'next 
<a href="<% Request.ServerVariables(SCRIPT_NAME) %><% if Request.QueryString("ed") = "open" then %>"<% else %>?<% Response.write(Request.QueryString) %>ed=open&"<% end if %> />My ed link</a><% if Request.QueryString("ed") = "open" then %><!-- paragraph goes here --><% End If %>



This also works fine with one exception. If the querystring contains, for example ?ec=open& then the link recalls the page with no query string.

Basically the problem is, whilst I've found a way to add multiple items to the query string one at a time, I can't work out how to remove them one at a time, it's all or nothing. I think I need something like an array, to determine which link removes which portion etc.

Any help on this, or suggestions for the improvement of what I've already written would be greatly appreciated. (I'm pretty much a newbie with ASP so anything complicated is probably beyond me at the moment.)

cheers.

Is This A Good Question/Topic? 0
  • +

Replies To: Asp Removing Single Item From Query String

#2 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Asp Removing Single Item From Query String

Posted 15 August 2003 - 08:16 AM

take the querystring and split it into an array using the & as the delimiter.

like this:
arrQuery = split(varQuery,"&")


um... yeah you might want to check the syntax and stuff since I've been thinking in php for too long... but something along those lines and then you can analyze each element of the array.
Was This Post Helpful? 0
  • +
  • -

#3 poab  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-June 02

Re: Asp Removing Single Item From Query String

Posted 15 August 2003 - 09:00 AM

Thanks very much :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1