Jump to content

Conditionally display buttons


Recommended Posts

I would like to conditionally display a button when a date condition has been met.  Now I am displaying the following button all the time, but it becomes obsolete at a certain point:

 

<button onclick="location.href='https://banjimmie.weebly.com/submit-picks-pass.html?rid=[@field:RID#]'" type="button">SUBMIT PICKS</button>

I would like to display this button only when a field in a table [@date] is on or before today's date.

 

Is this possible?

Thanks in advance

melissa

 

 

Link to comment
Share on other sites

try this :

<div id="b[@field:RID#]"></div>
<script>
var date= new Date('[@field:Date*]');
var today = new Date('[@cbTimestamp*]');
if (date < today){
document.getElementById('b[@field:RID#]').innerHTML = '<button onclick="location.href=\'https://banjimmie.weebly.com/submit-picks-pass.html?rid=[@field:RID]\'" type="button">SUBMIT PICKS</button> ';
} 
</script>

[@field:Date*] is needs to be replaced with the date field from picker

Link to comment
Share on other sites

May, you rock!  That worked.  However I have two buttons in this datapage, and it seems they affect each other.  So I a m wondering if I have to label the variables differently so the buttons behave independently.

Essentially one button appears after a date, and another button appears before a date.  I tried to change the name of the variables (e.g. var date1) but that doesn't seem to work.   Not sure if I need to change the "new Date" to something else, but that may be a standard term.

 

So I would need the same script but different IF statement (and can you do >= or <=?

 

<div id="b[@field:RID#]"></div>
<script>
var date= new Date('[@field:Date*]');
var today = new Date('[@cbTimestamp*]');
if (date  today){
document.getElementById('b[@field:RID#]').innerHTML = '<DIFFERENT BUTTON INFO> ';
} 
</script>

 

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...