SOLVED HOW TO display url as an icon or image only when url value exists

Is it possible to display a URL field in a grid with a clickable icon (like a clickable image hyperlink) ?

You can do this if you set the field to googlemaps, but I can’t see a way of doing this for just a normal URL field type.

At the moment the grid column displays the full URL value

Re: HOW TO display url as an icon or image only when url value exists

UPDATE - ok I have managed to do this using the sc_link macro and reading posts
http://www.scriptcase.net/forum_en_us/index.php?topic=6478.0
http://www.scriptcase.net/forum_en_us/index.php?topic=4786.0

HOWEVER my question is now having changed the field type from googlemaps to HTML Image, how do I get scritpcase to only display the HTML image when the field value is NOT blank ? . At the moment it displays the image in the column. Some of the images are clickable because it has a value to go to a URL , some of them you cannot click becuase the field value is empty. This can confusing for the end user as they may think that the hyperlink does not work rather than there being no value for the hyperlink

Re: HOW TO display url as an icon or image only when url value exists

Hi,
you might try something like this:

Change your field type to TEXT. (I suppose it’s a database field with the url in it)
In the onRecord event of the grid type some code like the following.


if(!empty({url_field}))
{
	sc_link(url_field,{url_field},,"Let's go somewhere else!","_blank");			
	{url_field}="<img src='http://www.freedigitalphotos.net/images/gal_images/av-_259.jpg'>"; // you can use your locally saved images scr='../lib/img/picture.png'
}

Nice, isn’t it?

Have fun
jsb

1 Like

Re: HOW TO display url as an icon or image only when url value exists

Hi jsb

Thx for the reply.

I managed to work something out myself and although not exactly the same code it was very similar

Now I need to find out how to wrap text in a PDF report…will create a new post for this if I can’t work it out myself :slight_smile:

Many thanks

En la lista de los campos le cambie al tipo texto y si me aparece la imagen muy bien, pero al momento de darle click no me enlaza a la URL, alguien me puede apoyar por favor?

El mensaje que me aparece al momento de darle click a la imagen es:

The requested URL /scriptcase/app/Desarrollo/grid_prueba/www.segob.gob.mx was not found on this server.