Solved

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

Posted on 2011-09-26
17
257 Views
Last Modified: 2012-06-22
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

0
Comment
Question by:Stiebel Eltron
  • 9
  • 7
17 Comments
 
LVL 15

Expert Comment

by:Eyal
ID: 36707029
<<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
 
LVL 15

Expert Comment

by:Eyal
ID: 36707471
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
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36707484
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
 

Author Comment

by:Stiebel Eltron
ID: 36707710
@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
 

Author Comment

by:Stiebel Eltron
ID: 36707714
@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
 
LVL 15

Accepted Solution

by:
Eyal earned 500 total points
ID: 36707777
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
 

Author Comment

by:Stiebel Eltron
ID: 36707877
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
 
LVL 15

Assisted Solution

by:Eyal
Eyal earned 500 total points
ID: 36707889
I accidentally wrote "" at the end
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Stiebel Eltron
ID: 36707997
@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
 

Author Closing Comment

by:Stiebel Eltron
ID: 36708001
Excellent!
0
 
LVL 15

Expert Comment

by:Eyal
ID: 36708032
<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
 

Author Comment

by:Stiebel Eltron
ID: 36708195
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
 
LVL 15

Expert Comment

by:Eyal
ID: 36708213
can also be a possibility. don't forget to put colspan="6"
0
 

Author Comment

by:Stiebel Eltron
ID: 36708266
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
 
LVL 15

Expert Comment

by:Eyal
ID: 36708275
I don't understand what you need. and more points well be cool :)
0
 

Author Comment

by:Stiebel Eltron
ID: 36708277
Please let me know if I need to open a new thread for that question...
0
 

Author Comment

by:Stiebel Eltron
ID: 36708282
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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now