Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-26
17
Medium Priority
?
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 

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 2000 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 2000 total points
ID: 36707889
I accidentally wrote "" at the end
0
 

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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to count occurrences of each item in an array.

721 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