Recordset Display Question

Discussion in 'ASP General' started by Maria Kovacs, Jan 27, 2004.

  1. Maria Kovacs

    Maria Kovacs Guest

    I am a begginner with ASP.
    Can someone help me fix this?
    I am trying to display order tracking links from a DB table.

    If there is a tracking link listed for a company it should display
    "Track Now" as a hyperlink. If there is no order tracking link listed
    it displays: "No Address".

    The link displays fine if I just use:
    <a href="<%=rs.Fields.Item("Order_Tracking").Value%>"><%=rs.Fields.Item("Order_Tracking").Value%></a>
    but I don't want that because some of the links are very long.

    PROBLEM: I have about 50 companies to display about 30 of them has a
    package tracking link provided. All displays however as "No Address".
    Here is the code I would like to use. Can someone put me in the right
    direction:
    <%
    If VIPPtracking = "" then
    Response.Write("<a href=""" &
    rs.Fields.Item("Order_Tracking").Value & """>Track Now</a>")

    else
    Response.write("No Address")
    End If
    %>
     
    Maria Kovacs, Jan 27, 2004
    #1
    1. Advertising

  2. Maria Kovacs

    Ray at Guest

    Where are you giving the VIPTracking variable its value?

    Ray at work


    "Maria Kovacs" <> wrote in message
    news:...

    >
    > PROBLEM: I have about 50 companies to display about 30 of them has a
    > package tracking link provided. All displays however as "No Address".
    > Here is the code I would like to use. Can someone put me in the right
    > direction:
    > <%
    > If VIPPtracking = "" then
    > Response.Write("<a href=""" &
    > rs.Fields.Item("Order_Tracking").Value & """>Track Now</a>")
    >
    > else
    > Response.write("No Address")
    > End If
    > %>
     
    Ray at, Jan 27, 2004
    #2
    1. Advertising

  3. Maria Kovacs

    Maria Kovacs Guest

    > Where are you giving the VIPTracking variable its value?
    >
    > Ray at work


    dim VIPPtrack
    dim grid_VIPPuserlinks_sql
    ....
    sub request_grid_VIPPuserlinks
    VIPPtrack = request("Order_Tracking")
    ....
    sub validate_grid_VIPPuserlinks
    VIPPtrack = trim(request("Order_Tracking"))
    ....
    sub db_select_grid_VIPPUserLinks
    grid_VIPPUserLinks_sql = "SELECT * FROM VIPP left join
    VIPPUserLinks....
    ....
    user_id = session("user_id")
    if user_id <> "" then
    db_select_grid_VIPPUserLinks
    end if
    ....

    <%
    do while not rs.EOF
    on error resume next
    ....
    VIPPtrack = rs("Order_Tracking")
    on error goto 0
    %>
    <table>With Order tracking code above and other related info like fax,
    phone #</table>
     
    Maria Kovacs, Jan 27, 2004
    #3
  4. Maria Kovacs

    Ray at Guest

    You're testing if VIPTrack="" and if it does = "", then it should write your
    link. Considering that you're assigning a value to VIPTrack in three
    different places from request.? collections and from a recordset, chances
    are the value is never or rarely "". Response.Write the value to see what
    it is. Or just use a test if/then like so:

    VIPTrack = Request.FORM("Order_Tracking")
    If VIPTrack = "" Then
    Response.Write "VIPTrack is not an empty string. It is: " & VIPTrack
    Else
    Response.Write "VIPTrack is an empty string.
    End If

    Also, please see here. http://www.aspfaq.com/show.asp?id=2111

    Ray at home

    "Maria Kovacs" <> wrote in message
    news:...
    > > Where are you giving the VIPTracking variable its value?
    > >
    > > Ray at work

    >
    > dim VIPPtrack
    > dim grid_VIPPuserlinks_sql
    > ...
    > sub request_grid_VIPPuserlinks
    > VIPPtrack = request("Order_Tracking")
    > ...
    > sub validate_grid_VIPPuserlinks
    > VIPPtrack = trim(request("Order_Tracking"))
    > ...
    > sub db_select_grid_VIPPUserLinks
    > grid_VIPPUserLinks_sql = "SELECT * FROM VIPP left join
    > VIPPUserLinks....
    > ...
    > user_id = session("user_id")
    > if user_id <> "" then
    > db_select_grid_VIPPUserLinks
    > end if
    > ...
    >
    > <%
    > do while not rs.EOF
    > on error resume next
    > ...
    > VIPPtrack = rs("Order_Tracking")
    > on error goto 0
    > %>
    > <table>With Order tracking code above and other related info like fax,
    > phone #</table>
     
    Ray at, Jan 28, 2004
    #4
  5. Maria Kovacs

    Maria Kovacs Guest

    I corrected all the Request.Form("item") collection names, and tried
    the code you gave me.

    Right now I am getting only: "VIPPtrack is not an empty string. It is:
    "
    no matter if there is a link or not. I never get "VIPTrack is an empty
    string."
     
    Maria Kovacs, Jan 28, 2004
    #5
  6. Maria Kovacs

    Ray at Guest

    Do you expect it to be an empty string ever? What kind of form element is
    it?

    Ray at home


    "Maria Kovacs" <> wrote in message
    news:...
    > I corrected all the Request.Form("item") collection names, and tried
    > the code you gave me.
    >
    > Right now I am getting only: "VIPPtrack is not an empty string. It is:
    > "
    > no matter if there is a link or not. I never get "VIPTrack is an empty
    > string."
     
    Ray at, Jan 28, 2004
    #6
  7. Maria Kovacs

    Maria Kovacs Guest

    If I write:
    <%
    If VIPPtracking = "" then
    Response.Write("No Address")

    else
    Response.write("<a href=""" & rs.Fields.Item("Order_Tracking").Value
    & """>Track Now</a>")

    End If
    %>

    Then I get "No Address" everywhere.
    ---
    If I reverse it:
    <%
    If VIPPtracking = "" then
    Response.Write("No Address")

    else
    Response.write("<a href=""" &
    rs.Fields.Item("Order_Tracking").Value & """>Track Now</a>")

    End If
    %>

    Then I get "Track Now" with the link of the portal's index page where
    there is no OrderTracking link provided,
    and
    get "Track Now" and the corresponding company's tracking link, where
    listed.

    I don't understand, in the case of NO tracking link listed, why would
    it use the portal's index page as a link?
     
    Maria Kovacs, Jan 28, 2004
    #7
  8. Maria Kovacs

    Ray at Guest

    This problem has nothing to do with writing links, portals, or recordsets or
    anything like that. It is all about the value of VIPTracking.

    Ray at home

    "Maria Kovacs" <> wrote in message
    news:...
    > If I write:
    > <%
    > If VIPPtracking = "" then
    > Response.Write("No Address")
    >
    > else
    > Response.write("<a href=""" & rs.Fields.Item("Order_Tracking").Value
    > & """>Track Now</a>")
    >
    > End If
    > %>
    >
    > Then I get "No Address" everywhere.
    > ---
    > If I reverse it:
    > <%
    > If VIPPtracking = "" then
    > Response.Write("No Address")
    >
    > else
    > Response.write("<a href=""" &
    > rs.Fields.Item("Order_Tracking").Value & """>Track Now</a>")
    >
    > End If
    > %>
    >
    > Then I get "Track Now" with the link of the portal's index page where
    > there is no OrderTracking link provided,
    > and
    > get "Track Now" and the corresponding company's tracking link, where
    > listed.
    >
    > I don't understand, in the case of NO tracking link listed, why would
    > it use the portal's index page as a link?
     
    Ray at, Jan 28, 2004
    #8
  9. Maria Kovacs

    Bob Lehmann Guest

    Have you tried Response.Write ( Request.Form("Order_Tracking")) with no logic around it, as Ray suggested?

    If it does have a value, then try this.....

    When I've run into this problem, this seems to do the trick....
    <%
    If Not VIPPtracking = "" then

    Response.write("<a href=""" & rs.Fields.Item("Order_Tracking").Value & """>Track Now</a>")

    else
    Response.Write("No Address")

    End If
    %>

    Bob Lehmann

    "Maria Kovacs" <> wrote in message news:...
    > If I write:
    > <%
    > If VIPPtracking = "" then
    > Response.Write("No Address")
    >
    > else
    > Response.write("<a href=""" & rs.Fields.Item("Order_Tracking").Value
    > & """>Track Now</a>")
    >
    > End If
    > %>
    >
    > Then I get "No Address" everywhere.
    > ---
    > If I reverse it:
    > <%
    > If VIPPtracking = "" then
    > Response.Write("No Address")
    >
    > else
    > Response.write("<a href=""" &
    > rs.Fields.Item("Order_Tracking").Value & """>Track Now</a>")
    >
    > End If
    > %>
    >
    > Then I get "Track Now" with the link of the portal's index page where
    > there is no OrderTracking link provided,
    > and
    > get "Track Now" and the corresponding company's tracking link, where
    > listed.
    >
    > I don't understand, in the case of NO tracking link listed, why would
    > it use the portal's index page as a link?
     
    Bob Lehmann, Jan 29, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gabriel Lozano-Morán

    How to loop a recordset and display html with conditions

    Gabriel Lozano-Morán, Jul 6, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    559
    Cactus Corp.
    Jul 6, 2005
  2. Hung Huynh
    Replies:
    8
    Views:
    331
    Bob Barrows
    Sep 24, 2003
  3. Dan Matthews

    Display last recordset

    Dan Matthews, Nov 24, 2003, in forum: ASP General
    Replies:
    7
    Views:
    140
    Dan Matthews
    Dec 8, 2003
  4. J.D. Buehls
    Replies:
    2
    Views:
    149
    J.D. Buehls
    Jun 16, 2004
  5. Replies:
    8
    Views:
    212
    Griff
    Feb 8, 2006
Loading...

Share This Page