Solved

Replace things in request.servervariables("QUERY_STRING")

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

713 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