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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Create Link from Filename?

Status
Not open for further replies.

robbie59

Technical User
May 9, 2001
36
US
I have a field that may return a number such as 589 or 1287 I need to turn these numbers into hyperlinks to an actual file based on the number of charaters such as if 589 is returned i need to make it into a hyperlink to or if a four digit number such as 1287 is returned i need to display a link such as 00001287.cmp basiclly I get a filename returned without the leading zeros I just need to add the leading zeros to the filename to = 8 total numbers and return it as a hyperlink to the file. I would be grateful for any help with this.

Rob
 
try something like this...
Code:
<%
strName = rs(&quot;filename&quot;) 'eg 589 or 1287
intZeroes = 8-Len(strName)

For i = 1 To intZeroes
  strName = &quot;0&quot; & strName
Next

Response.Write &quot;<A HREF='[URL unfurl="true"]http://files/&quot;[/URL] & strName & &quot;.cmp'>link text here</A>&quot;
%>

Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
I am a beginner at this sort of stuff. the link will be inside a table do I place all of this code inside the table cell to creat the link or do I only place the linking responce.Write portion of it inside the cell, I seem to be getting and error when I place the code with the recordset as the number as shown below
<%
strName = <%=(Recordset1.Fields.Item(&quot;JobNumber&quot;).Value)%>
intZeroes = 8-Len(strName) For i = 1 To intZeroes
strName = &quot;0&quot; & strName
Next

Response.Write &quot;<A HREF=' & strName & &quot;.cmp'>link text here</A>&quot;
%>

If knowledge were power I would be a AAA battery!
 
Dear Tony:


THANK YOU! THANK YOU! THANK YOU! I figured out how to insert the code and it works great! I have been trying to figure this on out for days and your code did it for me.

Rob

If knowledge were power I would be a AAA battery!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top