Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax to concatenate a HREF together? 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I want to be able to track UPS packages from our site.
I managed to get the correct URL but I need to add the tracking number from our database.
In my code below I get and error on UPS's web site because it is only passing everything up to the
& <%=RS2(&quot;tracknum&quot;)%>
What is the correct syntax to concatenate a HREF together?

<p><a href=&quot; & <%=RS2(&quot;tracknum&quot;)%> & &quot;&track.x=34&track.y=10&quot;>track me</a></p>
---------------
Also I would like to call this page which is trackups.asp and have it look up the =RS2(&quot;tracknum&quot;) and just go ahead and open the Href without having to click something else.
In other words I just need the HTML code to force my .ASP to open and passs the tracking number too.
TIA DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Try reading the recordset value into a variable, and then using that, instead of doing it straight from the recordset.

Furthermore, you may with to assign it like this:

urlString = cstr(rs2(&quot;tracknum&quot;)

I have had troubles in the past with trying to do it straight from the recordset.

If that doesn't fix the problem, then you may want to build up the entire url into a variable, just concatenating as you have above, and then do the write of the whole urlString.

If you want your page to redirect automatically, you can use the response.redirect(urlString) method to do that.

If there have been headers written to the page before you call the method, be sure to set your response.buffer = true

good luck! :)
Paul Prewett
 
Ok I was able to concatenet the whole URL together and prin tht variable so its all one enity now
but...
here's new code with a different error

MyTrack = trim(RS2(&quot;tracknum&quot;))
WholeLInk = &quot; & MyTrack & &quot;&track.x=34&track.y=10&quot;
Response.Write WholeLInk
%>
<p><a href=<WholeLInk>track me</a></p>
-------------------------
So when I click the link I get this in my URL

which gives the error &quot;Page not found...&quot;

What is the correct sytax for passing a variable to the Href.
This does not work:
<p><a href=<WholeLInk>track me</a></p>
Not does this
<p><a href=<=WholeLInk>track me</a></p>

TIA DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
<p><a href=<%=WholeLInk%>>track me</a></p>

You only forgot the %'s and one '>' --

Also note that there's no need to response.write the wholeLink variable right after you assign it... only when you are assigning it to the href tags.

hope that clears things up! :)
Paul Prewett
 
Cool
I also figured this out myself

<%@ Language=VBScript%>
<%response.buffer=true%> <<<<<<<< adding this line from your prevois post above >>>>>>
<html>
<head>
<title>BarcodeONE UPS Tracking Station</title>
</head>

MyTrack = trim(RS2(&quot;tracknum&quot;))
WholeLink = &quot; & MyTrack & &quot;&track.x=34&track.y=10&quot;
Response.Write WholeLink
response.redirect WholeLink <<<<< and using this
%>
</body>
</html>
-----------------------
So when the page is opened it looks up the tracking number and then open's the UPS tracking page at the same time.
this is too cool.
the reason I &quot;wrote&quot; the 'WholeLink&quot; variable was only to see if it contained the whole string which was my original problem.

here give it a try:

Thanks a bunch &quot;Link9&quot;
how about a Star!!!!
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
You might wanna note this, too...

I see that you aren't writing any html at all to the page above. Is that the whole page, or did you just post a fragment???

If you aren't writing ANYTHING to the page, then you don't have to write any html headers to it at all -- only the asp script that is between the <%%>'s --

You won't have to set the response.buffer to true if you do that, and the page, itself, won't even show up in the user's history. So, say, they hit 'Back' -- it will take them to the page before that... completely transparent... you can use that method for login scripts and other such applications

Ever notice that sometimes at some sites, the screen will just go blank, and then you will hear <<click>> and away you go to another page??? That's what they are doing -- redirecting based on browser type, login name, tracking number, whatever --

good luck! :)
Paul Prewett
 
No that's the whole page. I still have a lot to learn about this HTML and ASP.
your the BEST man!!!
2 Stars is a charm.

If you ever need any MS Access Help I'm your man DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top