Solved

Replace things in request.servervariables("QUERY_STRING")

Posted on 2009-07-13
5
598 Views
Last Modified: 2012-06-21
I have a link to switch between languages.
So what I need to do is search in request.servervariables("QUERY_STRING") if there is a "&lg=1" or "&lg=2" in string then remove it.
Example:
request.servervariables("QUERY_STRING") = http://www.mysit.com/products.asp?id_product=1&tab=2&lg=1
I need it to return only until http://www.mysit.com/products.asp?id_product=1&tab=2
Please, help!
Thanks in advance!

<%if idioma = 2 then%>
<a href="<%=request.servervariables("URL")%>?<%=request.servervariables("QUERY_STRING")%>&lg=1">LINK to language 1<a>
<%else%>
<a href="<%=request.servervariables("URL")%>?<%=request.servervariables("QUERY_STRING")%>&lg=2">LINK to language 2<a>
<%end if%>

Open in new window

0
Comment
Question by:drix76
  • 2
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24844893
you mean:
<%
Dim qs
qs = request.servervariables("QUERY_STRING")
qs = replace(qs, '&1g=1', '')
qs = replace(qs, '&1g=2', '') 
if idioma = 2 then%>
<a href="<%=request.servervariables("URL")%>?<%=qs%>&lg=1">LINK to language 1<a>
<%else%>
<a href="<%=request.servervariables("URL")%>?<%=qs%>&lg=2">LINK to language 2<a>
<%end if%>

Open in new window

0
 

Author Comment

by:drix76
ID: 24844928
Thank you for your quick answer, but it didn't work... The &lg=1 or 2 is still in qs

<%
Dim qs
qs = request.servervariables("QUERY_STRING")
qs = replace(qs, "&1g=1", "")
qs = replace(qs, "&1g=2", "")
response.write qs
' it results products.asp?id_product=1&tab=2&lg=1 still
%>
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 480 total points
ID: 24844937
is that a 1 (one) or l (letter L) ?


qs = replace(qs, "&lg=1", "")
qs = replace(qs, "&lg=2", "") 

Open in new window

0
 
LVL 9

Assisted Solution

by:rg20
rg20 earned 20 total points
ID: 24844945
He code you have above has a "1g". Not "lg". One vs L would not work
0
 

Author Closing Comment

by:drix76
ID: 31603064
Thank you both very much!!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FileUp - Classic ASP 5 19
ASP exit 10 18
IIS 7 and executing pages using localhost 16 13
Reg Exp to extract Url from string asp 12 14
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question