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: [efi-revivo] different images when field are empty/value

By Dave - February 2, 2009

Hi efi-revivo,

Try this:

<script type="text/javascript">
<?php if ($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>');
<?php endif ?>
</script>


or another way:

<?php if ($record['web_site']): ?>
<script type="text/javascript">
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>
<?php endif ?>


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

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: [Dave] different images when field are empty/value

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