different images when field are empty/value

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 2, 2009   (RSS)

I'm new in php and I'm try to show different images when the field are empty (show no.jpg) and when the field with some value (show yes.jpg) - using javascript or php code:

<script type="text/javascript">
if ('<?php echo $record['web_site'] ?>')
{
document.write('<a href="http://<?php echo $record['web_site'] ?>"><img src="imagesnew/yes.jpg" title="Web-site" width="26" height="26" border="0" /></a>');
}
</script>


* If you know how to do it with php code it will be better..

Re: [Dave] different images when field are empty/value

thanks dave it's ok but I want to see the no.jpg image when the field is empty.

Re: [efi-revivo] different images when field are empty/value

By Dave - February 2, 2009

Ok, do you need javascript at all? How about this:

<?php if ($record['web_site']): ?>
<a href="http://<?php echo $record['web_site'] ?>"><img src="imagesnew/yes.jpg" title="Web-site" width="26" height="26" border="0" /></a>
<?php else: ?>
<img src="no.jpg" />
<?php endif ?>
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] different images when field are empty/value

Thanks dave it's work now like i want :-)