Jump to content

Turning a Column in an ASP Page into Links


Eugene45

Recommended Posts

Hi Guys, I have an ASP form in the form of a table. Well I need only one column or field in the table to appear as links to documents on my local drive.

<%option explicit%><!-- #include file="adovbs.inc"--> <html><head><title>ADO - List Database Records</title></head><body><%Dim oConn, oRs, strConnstrConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= C:/Inetpub/wwwroot/MyWebProjects/Manual.mdb" Set oConn=Server.CreateObject("ADODB.Connection")oConn.Open strConn Set oRs=Server.CreateObject("ADODB.Recordset")oRs.Open "Orders",oConn,adOpenForwardOnly,adLockReadOnly,adCmdTableoRs.MoveFirst%><TABLE BORDER=1 COLS=<% = oRs.Fields.Count %>>   <TR>    <%Dim oField 	For Each oField In oRs.Fields %>	  <TH> <% = oField.Name %></TH>	  <% Next %>	  </TR><%Do While Not oRs.EOF %>   <TR>   <%For Each oField In oRs.Fields%>[color="#FF0000"][/color][color="#FF0000"]Note: this is where i think i need to add code to instruct my asp program to single out one field to become only links to documents[/color]       <TD ALIGN=RIGHT>	   <%If IsNull(oField) Then	       Response.Write " "		  Else		   Response.Write oField.Value		 End If  	   %>	   	   </TD>	   <% Next	   oRS.MoveNext%>	   </TR>	<% Loop %></TABLE><%	oRs.CloseSet oRs = NothingoConn.CloseSet oConn = Nothing%><h3>    <A HREF="Records1_2.htm">Click here to add a Form</A></h3></body></html>  

Thank you all in advance

Link to comment
Share on other sites

I have a few asp pages that pull up links from a db and it's relatively simple to do.Essentially what you need to do is to take the data from the relevant column and insert it into the href section of the <a> taghttp://www.amjohnson.co.uk/website.asp is built up from a db.Key code line is

<td align=center><a href="<%= rstSimple2.Fields("url").Value %>" target="_blank">Link</a>

In place of Link I could have taken a description from a field in the db.Using the simple db view pages from the ASP101 sample pages.

Link to comment
Share on other sites

I have a few asp pages that pull up links from a db and it's relatively simple to do.Essentially what you need to do is to take the data from the relevant column and insert it into the href section of the <a> taghttp://www.amjohnson.co.uk/website.asp is built up from a db.Key code line is
<TABLE BORDER=1 COLS=<% = oRs.Fields.Count %>>   <TR>    <%Dim oField 	For Each oField In oRs.Fields %>	  <TH> <% = oField.Name %></TH>	  <% Next %>	  </TR><%Do While Not oRs.EOF %>   <TR>   <%For Each oField In oRs.Fields%>       <TD ALIGN=RIGHT>[color="#9ACD32"]This is where you may need to look[/color]	   <A HREF= "<%= oRs.Fields("Link")%>">Click </A>	   <%If IsNull(oField) Then	       Response.Write " "		  Else		   Response.Write oField.Value		 End If  	   %>	   	   </TD>	   <% Next	   oRS.MoveNext%>	   </TR>	<% Loop %></TABLE>

<A HREF= "<%= oRs.Fields("Link")%>">Click </A>The output is i would say almost close to what i am trying to accomplish.Let me define a few things for you: "Link" is the name of the Field/Column I am trying to turn into links such that when a user clicks on any text in this field it would open a document."Click" was just a test I put in there to see what would happen when i run my ASP pageFinally,The output is like thisIn the field named "Link" there are text values there but now when i run my code "Click" appears beside this text values in this Field(Link)What i am trying to do is make those text values in the field (Link) become links to documents on my local drive. "Click" does not link to anything it just appears as a text with an underline.The most tricky part is I dont want to supply the texts to this Field (link) in code i want to be able to suppy it in an HTML form and post it to my database as a link that opens up documents on my local or network drive.Thank you very much for your help.Any suggestions you have are welcomed.Thank you.

Link to comment
Share on other sites

First, Thank you for your helpI tried what you showed me above and it sort of works. But below is what i did and I am not sure where i am going wrong
<TABLE BORDER=1 COLS=<% = oRs.Fields.Count %>>   <TR>    <%Dim oField 	For Each oField In oRs.Fields %>	  <TH> <% = oField.Name %></TH>	  <% Next %>	  </TR><%Do While Not oRs.EOF %>   <TR>   <%For Each oField In oRs.Fields%>       <TD ALIGN=RIGHT>[color="#9ACD32"]This is where you may need to look[/color]	   <A HREF= "<%= oRs.Fields("Link")%>">Click </A>	   <%If IsNull(oField) Then	       Response.Write " "		  Else		   Response.Write oField.Value		 End If  	   %>	   	   </TD>	   <% Next	   oRS.MoveNext%>	   </TR>	<% Loop %></TABLE>

<A HREF= "<%= oRs.Fields("Link")%>">Click </A>The output is i would say almost close to what i am trying to accomplish.Let me define a few things for you: "Link" is the name of the Field/Column I am trying to turn into links such that when a user clicks on any text in this field it would open a document."Click" was just a test I put in there to see what would happen when i run my ASP pageFinally,The output is like thisIn the field named "Link" there are text values there but now when i run my code "Click" appears beside this text values in this Field(Link)What i am trying to do is make those text values in the field (Link) become links to documents on my local drive. "Click" does not link to anything it just appears as a text with an underline.The most tricky part is I dont want to supply the texts to this Field (link) in code i want to be able to suppy it in an HTML form and post it to my database as a link that opens up documents on my local or network drive.Thank you very much for your help.Any suggestions you have are welcomed.Thank you.

Thank you very much i have accomplished what i am trying to do.I have turned each text in that field into a column.Thank you so muchPlease ignore my last post
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...