Recordset Display Question

M

Maria Kovacs

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
%>
 
M

Maria Kovacs

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>
 
R

Ray at

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
 
M

Maria Kovacs

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."
 
R

Ray at

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

Ray at home
 
M

Maria Kovacs

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?
 
R

Ray at

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
 
B

Bob Lehmann

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top