Forums

This topic is locked

If, Then, Else statement

Posted 05 Jun 2002 19:54:44
1
has voted
05 Jun 2002 19:54:44 Mitchel Tendler posted:
I have the following code on a page:

<%
if Session("lang" = "sv" then
response.redirect("sv.html"
else
if Session("lang" = "sv-fi" then
response.redirect("sv-fi.html"
else
if Session("lang" = "en-gb" then
response.redirect("en-gb.html"
else
if Session("lang" = "en-us" then
response.redirect("en-us.html"
else
response.redirect("nodetect.html"
end if
end if
end if
end if
%>

The code works fine, except if there are 2 languages set in the browser.

I noticed that if I have 2 languages set on my browser, like "en-us" and "en-gb" that the "Session("lang" variable = "en-us,en-gb;q=0.5" which totally messes up my statement.

Is there a way to replace the "=" in the statment with something that would be more like a "contains" or "like" statement? LIKE does not work <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Thanks!

Mitch

When in doubt...reboot!

Replies

Replied 05 Jun 2002 21:49:18
05 Jun 2002 21:49:18 Owen Eastwick replied:
Try:

&lt;%
varLang = Session("lang"

If varLang = "sv" Then
response.redirect("sv.html"
ElseIf varLang = "sv-fi" Then
response.redirect("sv-fi.html"
ElseIf InStr(varLang, "en-gb" &lt;&gt; 0 Then
response.redirect("en-gb.html"
ElseIf InStr(varLang, "en-us" &lt;&gt; 0 Then
response.redirect("en-us.html"
Else
response.redirect("nodetect.html"
End If
%&gt;





Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 05 Jun 2002 21:56:21
05 Jun 2002 21:56:21 Mitchel Tendler replied:
Thanks Owen...I'll give it a shot!

Mitch

When in doubt...reboot!

Reply to this topic