This topic is locked

Easiest way to show/hide image based on hyperlink?

3/14/2009 12:09:09 PM
ASPRunnerPro General questions
A
aspdummy author

ASPrunner 6.0 Build 766
On my view page, I have a simple hyperlink displayed with the code:

<P align=center>{$show_Vis_Tour_Link}</P>


Then in the "View As" settings I have selected "hyperlink" and clicked "Display Word" then entered text "Click for Visual Tour" This works fine as the "Click for Visual Tour" link shows up if I have entered a website in the database and the area is blank if there is no entry.
I would like to set this up so an image (also hyperlinked to the same Vis_Tour link) will show up when the site is present and disappear when there is no entry. I've played around with some if/then statements but don't seem to be coming up with the exact thing I need.
So basically, given a web site entered in the database, what is the best way to display an image hyperlinked to that site, but have the image disappear when no web site is entered?

J
Jane 3/16/2009

Hi,
you can use custom format for this field on the "View as" settings dialog on theVisual Editor tab.

Here is just a sample:

if strValue<>"" then

strValue = "<a href=""" & strValue & """><img src=""images/yourimage.jpg""></a>"

end if

A
aspdummy author 3/22/2009

This seems to work except for a couple of small hitches...
I use the same link on the "List" page and again on the "View" page. I actually want it to be just a hyperlink saying 'Click Here' on the List page, but would like to display the linked image on the View page. If I go to the View page, View As settings and select 'custom code' it automatically changes the link on the List page as well. Likewise, if I set the List page 'View As' back to hyperlink, it automatically changes the View page back to hyperlink, too. To fix this, I added a line to the SQL Query which calls this field again and gave it an alias. I then used the alias on the view page and the normal field on the list page.
The second issue is when the link is generated, the URL for the page is appended to the link, so it comes out something like:
http://...../current_listings/retblresults_view.asp?editid1=223#http://www.visualtour.com/applets/flashviewer2/viewer.asp...#
when all I really want is the "http://www.visualtour.com/..."; portion which is the actual field value. Is there any way to use the href statement so the actual field will be the link?

J
Jane 3/23/2009

Hi,
to show your actual link add http:// as URL prefix on the "View as" settings dialog on theVisual Editor tab.
Also you can use custom format to create hyperlink.

Here is a sample code:

strValue = "<a href=""" & strValue & """>Click here</a>"