How to set the ordinary label link to be the image be the link using ASP?

Dear EE experts,

We would like to ask for tech support on how to change the ordinary label link, to set be image link using ASP.
Kindly see the attached codes for the sample that we have at this moment, the show image is up to 5 photos max. So it has image1, image2, image3, image4, & image5. Then for the DOWNLOAD link, it has 5 also, download1, download2, download3, download4, & download5. But from the attached download codes, it has 3 only (just for you to see the codes only).

The point is, we would like to combine the link with the image that if the USER LOGIN = TRUE, then the IMAGE would be clickable and would go to the link as same as the download link.

Kindly advise on how to combine it...

Thank you & hope to hear from experts soon!
:-)
<<SHOW IMAGE>>
<table width="78%" border="0" cellspacing="3" cellpadding="1">
  			<tr> 
				<% 
				dim i
			    i=0
				Do Until rsProducts.EOF 
				if not rsProducts.eof then
				image1 = rsProducts("image1")
				image2 = rsProducts("image2")
				image3 = rsProducts("image3")
				image4 = rsProducts("image4")
				image5 = rsProducts("image5")
				 product_name = rsProducts("product_name")
				 download1 = rsProducts("download1")
				 download2 = rsProducts("download2")
 				 download3 = rsProducts("download3")
				 download4 = rsProducts("download4")				 
				 download5 = rsProducts("download5")				 
				end if
			   	%>
		    	<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">
                <%if not Image1="" then%>
					<img src="photo/<%=image1%>" alt="<%=product_name%>"/>
                <%end if%>
                </td>
		    	<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
                <%if not Image2="" then%>
					<img src="photo/<%=image2%>" alt="<%=product_name%>"/>
                <%end if%>
                </td>
		    	<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">
                <%if not Image3="" then%>
                	<img src="photo/<%=image3%>" alt="<%=product_name%>"/>
				<%end if%>
                </td>
		    	<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
				<%if not Image4="" then%>
					<img src="photo/<%=image4%>" alt="<%=product_name%>"/>
                <%end if%>
                </td>
		    	<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
                <%if not Image5="" then%>
					<img src="photo/<%=image5%>" alt="<%=product_name%>"/>
                <%end if%>
                </td>    
			</tr>
-------------------------------------------------
<<SHOW LINK "DOWNLOAD" IF USER LOGIN = TRUE>>
<tr>
		    	<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
   				    <%
        				If Session("loggedIn") = true Then
            			Response.Write "<a href=""" & Replace(download1, "DOWNLOAD", "photo/download") & """>DOWNLOAD</a>"
						
						End If
    				%>
                 </td>
	             <td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
   				    <%
        				If Session("loggedIn") = true Then
            			Response.Write "<a href=""" & Replace(download2, "DOWNLOAD", "photo/download") & """>DOWNLOAD</a>"
						
						End If
    				%>
                 </td>
	             <td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
   				    <%
        				If Session("loggedIn") = true Then
            			Response.Write "<a href=""" & Replace(download3, "DOWNLOAD", "photo/download") & """>DOWNLOAD</a>"
						
						End If
    				%>
                 </td>
			<%
			if i>2 then
			%>
		</tr>

Open in new window

Stiebel EltronAsked:
Who is Participating?
 
EyalConnect With a Mentor Commented:
what are you trying to accomplish?

it was a while since I wrote classic ASP so here is fixed version

<table width="78%" border="0" cellspacing="3" cellpadding="1">
	<tr> 
				<% dim iRow
				iRow=0
				Do Until rsProducts.EOF 
				image1 = rsProducts("image1")
				image2 = rsProducts("image2")
				image3 = rsProducts("image3")
				image4 = rsProducts("image4")
				image5 = rsProducts("image5")
				 product_name = rsProducts("product_name")
				 download1 = rsProducts("download1")
				 download2 = rsProducts("download2")
 				 download3 = rsProducts("download3")
				 download4 = rsProducts("download4")				 
				 download5 = rsProducts("download5")				 
			   	%>
	    	<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">
                	<%= GetImage(Image1,download1,product_name)%>
                </td>
		<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
                	<%= GetImage(Image2,download2,product_name)%>
                </td>
		<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">
			<%= GetImage(Image3,download3,product_name)%>
                </td>
		<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
			<%= GetImage(Image4,download4,product_name)%>
                </td>
		<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
			<%= GetImage(Image5,download5,product_name)%>
                </td>
	</tr>

<%
	iRow = iRow + 1
	if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
	<tr><td colspan="5" bgcolor="#FFFFFF"></td></tr>
	<%end if
	rsProducts.MoveNext()
Loop

Function GetImage(Image,download,productname)
	dim RV
	RV = ""
	if Trim(Image & "") <>"" then
		If Session("loggedIn") = true Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &"""/>"
		If Session("loggedIn") = true Then
			RV = RV & "</a>""
		End If
	end if
	GetImage = RV
End Function
%>

Open in new window

0
 
EyalCommented:
<<SHOW IMAGE>>
<table width="78%" border="0" cellspacing="3" cellpadding="1">
	<tr> 
				<% 
				Do Until rsProducts.EOF 
				image1 = rsProducts("image1")
				image2 = rsProducts("image2")
				image3 = rsProducts("image3")
				image4 = rsProducts("image4")
				image5 = rsProducts("image5")
				 product_name = rsProducts("product_name")
				 download1 = rsProducts("download1")
				 download2 = rsProducts("download2")
 				 download3 = rsProducts("download3")
				 download4 = rsProducts("download4")				 
				 download5 = rsProducts("download5")				 
			   	%>
	    	<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">
                	<%= GetImage(Image1,download1,product_name)%>
                </td>
		<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
                	<%= GetImage(Image2,download2,product_name)%>
                </td>
		<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">
			<%= GetImage(Image3,download3,product_name)%>
                </td>
		<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
			<%= GetImage(Image4,download4,product_name)%>
                </td>
		<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
			<%= GetImage(Image5,download5,product_name)%>
                </td>
	</tr>

<%
End Do

Function GetImage(Image,download,productname)
	dim RV
	RV = ""
	if Trim(Image & "") <>"" then
		If Session("loggedIn") = true Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &"""/>"
		If Session("loggedIn") = true Then
			RV = RV & "</a>""
		End If
	end if
	GetImage = RV
End Function
%>

Open in new window

0
 
EyalCommented:
and I think it will be better also to do all the design with CSS and not in attributes (not relevant to the question asked)
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Kiran SonawaneProject LeadCommented:
You can do like this
<% If Session("loggedIn") = true Then %>
      <a href='<%=Replace(download1, "DOWNLOAD", "photo/download")%>'>DOWNLOAD</a>
<% End If %>

Open in new window

0
 
Stiebel EltronAuthor Commented:
@Eyal: I've tried what you advised, but I'm having error on this line: End Do

Btw, I have below code, after that </tr> , from the code attached above:
<%
                  if i>2 then
                  %>
            </tr>

Kindly see the attached code for the additional code...
<tr>
	
    		<% 
			i=0
				else
			i=i+1
			end if
        	rsProducts.MoveNext 
    		Loop 
			if i<>0 and (4-i)<>0 then
	   		%>
	   			<td colspan="<%=(4-i)%>" bgcolor="#FFFFFF">&nbsp;</td>
	   		<%
			end if
			%>
  		</tr>

Open in new window

0
 
Stiebel EltronAuthor Commented:
@sonawanekiran: I think what you advise is almost the same as what I have already...
What we need is to replace that word "DOWNLOAD", and be the IMAGE be the clickable if the user LOGIN = TRUE then the image with be clickable & direct to its link...
0
 
Stiebel EltronAuthor Commented:
What I'm trying to accomplish is to replace that link word "DOWNLOAD", and be the image be clickable if user LOGIN = TRUE.
I tried your code, and here's the error result I received:
Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/iphoto/asia/ste-shower-units.asp, line 191

RV = RV & "</a>""
-----------------^

Hope to hear again soon...
:-)
0
 
EyalConnect With a Mentor Commented:
I accidentally wrote "" at the end
0
 
Stiebel EltronAuthor Commented:
@Eyal: Got it! it worked! But have some questions, though I accept that as solution already...
- how to remove the image border?
- how to add the product name on the upper left (before the image)?
Ex. AQ 35E
0
 
Stiebel EltronAuthor Commented:
Excellent!
0
 
EyalCommented:
<table width="78%" border="0" cellspacing="3" cellpadding="1">
      <tr>
                        <% dim iRow
                        iRow=0
                        Do Until rsProducts.EOF
                        image1 = rsProducts("image1")
                        image2 = rsProducts("image2")
                        image3 = rsProducts("image3")
                        image4 = rsProducts("image4")
                        image5 = rsProducts("image5")
                         product_name = rsProducts("product_name")
                         download1 = rsProducts("download1")
                         download2 = rsProducts("download2")
                          download3 = rsProducts("download3")
                         download4 = rsProducts("download4")                        
                         download5 = rsProducts("download5")                        
                           %>
                <td style="backgroun-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;">
                      <%= product_name%>
                </td>
                <td align="center" bordercolor="#999999" bgcolor="#FFFFFF">
                      <%= GetImage(Image1,download1,product_name)%>
                </td>
            <td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
                      <%= GetImage(Image2,download2,product_name)%>
                </td>
            <td align="center" bordercolor="#999999" bgcolor="#FFFFFF">
                  <%= GetImage(Image3,download3,product_name)%>
                </td>
            <td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
                  <%= GetImage(Image4,download4,product_name)%>
                </td>
            <td align="center" bordercolor="#999999" bgcolor="#FFFFFF">                
                  <%= GetImage(Image5,download5,product_name)%>
                </td>
      </tr>

<%
      iRow = iRow + 1
      if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
      <tr><td colspan="6" bgcolor="#FFFFFF"></td></tr>
      <%end if
      rsProducts.MoveNext()
Loop

Function GetImage(Image,download,productname)
      dim RV
      RV = ""
      if Trim(Image & "") <>"" then
            If Session("loggedIn") = true Then
                  RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
            End If
            RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
            If Session("loggedIn") = true Then
                  RV = RV & "</a>""
            End If
      end if
      GetImage = RV
End Function
%>
0
 
Stiebel EltronAuthor Commented:
Thank you very much! Kindly see the attached script, as I insert it above the row of the images... It's working as well... :-)

Thank you!
<tr>
    		<td style="background-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;">
                      <%= product_name%>
        	</td>
    	</tr>
		<tr>
	    	<td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
                	<%= GetImage(Image1,download1,product_name)%>
                </td>

Open in new window

0
 
EyalCommented:
can also be a possibility. don't forget to put colspan="6"
0
 
Stiebel EltronAuthor Commented:
Ok, noted.
I'm not sure if I need to open a new thread for this additional question that is related with the product name...
- How if there would be another product name BUT same SeriesID, how to put it on the next row & not be included on the same row?
0
 
EyalCommented:
I don't understand what you need. and more points well be cool :)
0
 
Stiebel EltronAuthor Commented:
Please let me know if I need to open a new thread for that question...
0
 
Stiebel EltronAuthor Commented:
Ok ok... Lol! Will open a new thread for this to give u more points! :-)
Hope to hear from you to my new thread...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.