Jump to content

Display Small Graphic if expired is less than today ?


Recommended Posts

I have a field [@field:Expiration_Date] . I would like to display a small 75 x 50 graphic "Expired" using JavaScript in an Html Block only if Today() is greater than the expiration date. This is a results page where rules are not available. I am pretty sure this can be done with an <img> tag, JavaScript and an Html Block. I just don't know the proper syntax.  Would appreciate any help ?  Thanks You !

Unsuccessfully Tried This:

<script>

expired = [@field:Employee_Doc_Date_Plus_Renew*].value;
today=[@field:Date_Time_Stamp*].value;

if (expired < today)
{
 <img alt="" src="https://www.mysite.net/Expired_76x50.png" style="width: 76px; height: 50px;" /> ;
}
</script>

Link to comment
Share on other sites

Took me a while to figure out. Here is what worked for me if anyone else needs it.

<script>
var now = new Date();
var expiration = new Date("[@field:Employee_Doc_Date_Plus_Renew*]");

if(now > expiration) // today is after expiration

  document.write("<IMG ALIGN='center' "+
                    "SRC='https://My URL/Expired_76x50.png'> "); 
</script>

You will need to replace My URL with the actual URL where your image resides as well as your actual @field references.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...