SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if statement based on url and query string

    Hi,
    I am working with a classic ASP website and I only know the fundamentals of programming. I am trying to display an image everywhere on my site except for one page. This page would receive a different image.

    By using the following code I was able to have the image change for a section of my site(site.com/page.asp) but I haven't been able to figure out how to change it for a specific page (site.com/page.asp?ID=123).

    Code ASP:
    <% IF Request.ServerVariables("SCRIPT_NAME") = "/AboutUs.asp" THEN %>
    				<img src="/img/img.jpg" border="0" />
                    <% ELSE %>
    			<a href="/AboutUs.asp?ID=200"><img src="/img/img2.jpg" border="0" /></a>
    			<% END IF  %>

    I found another forum suggesting to use the following code but pasting it in the table cell I want the image to appear in broke the site. If the following code is the correct solution I am not sure how to use it.

    Code ASP:
    var url = "<%=Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Querystring%>";
    if(url == "site.com/page.asp?ID=123")
    {
        //Do stuff
    }

    Any help would be greatly appreciated. Thanks!
    Paul

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <% IF (Request.ServerVariables("SCRIPT_NAME") = "page.asp") And (Request("ID")="123") THEN %>

  3. #3
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That did it! Thank you very much.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •