[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

how to you c:if tag ?


how to implement JSTL (maybe c:if) to do the following:-


 String sImageUrl = JP.getPreviewImageURL((DbNode)imgNode, 500, 500);  // url to the image with width and height
             String sImageFull =  JP.getPreviewImageURL((DbNode)imgNode, 700, 700);  // url to the image with width and height


<a href="GetPreview.jsp?">
          <img src="<%=sImageUrl%>">
          </a>


if user clicks of the anchor <a> then I want to change the
img source to the large image ie --

 <img src="<%=sImageFull%>">


awaiting a rresponse

thanks
0
sdesar
Asked:
sdesar
  • 9
  • 4
1 Solution
 
kennethxuCommented:
jstl cannot do this!
you need javascript to do it.
0
 
kennethxuCommented:
or if you can discribe more detail of your problem. hope I'll see it differently.
0
 
sdesarAuthor Commented:
Ok JavaScript should be okay for Onclick to check if its true .., but I think

if the onClick enent is true then I want to display <img src="<%=sImageFull%>">
else default is
<img src="<%=sImageUrl%>">




I just need to display a larger size image when the user clicks on the <a> tag and display this img src tag <img src="<%=sImageFull%>">

-Hope this helps
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
kennethxuCommented:
then you'll have to pass a parameter to sever.
0
 
kennethxuCommented:
or you can use javascript to change the image src righ in place.
0
 
sdesarAuthor Commented:
could you please give me the syntax for the JavaScript .. if that is easier

awaitng a reposnse
0
 
kennethxuCommented:
give you img tag and id and get the tag, then tag.scr=newimageurl
0
 
kennethxuCommented:
try:

<img src="<%=sImageUrl%>" onclick="this.src='<%=sImageFull%>'" >
0
 
sdesarAuthor Commented:


I think all I need is to check is <a> tag is clicked then display <%=sImageFull%>
using JSTL c:if .. is that possible?

here is what I tried with your suggestion and it is NOT working

  <%-- OnClick
        <a href="GetPreview.jsp?"  onclick="this.src="<%=sImageFull%>"> <img src="<%=sImageUrl%>" > </a>

      --%>
HTML result
 
            <a href="http://rabbits10.jpg&width=3065&height=2176&format=jpg" > 
        <img src="http://rabbits10.jpg&width=500&height=500&format=jpg">
          </a>


so i see that its being outputed in HTML source but not on the HTML screen
0
 
kennethxuCommented:
>> here is what I tried with your suggestion and it is NOT working
I told you to do this:
<img src="<%=sImageUrl%>" onclick="this.src='<%=sImageFull%>'" >
0
 
sdesarAuthor Commented:
Here are your Excellent points!

This works!

img src="<%=sImageUrl%>" onclick="this.src='<%=sImageFull%>'" >



Thanks a million!
0
 
kennethxuCommented:
glad to know and my pleasure :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 9
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now