Solved

Replace things in request.servervariables("QUERY_STRING")

Posted on 2009-07-13
5
593 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 142

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 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

930 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now