pgjacob Posted March 6, 2018 Report Share Posted March 6, 2018 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 Quote Link to comment Share on other sites More sharing options...
MayMusic Posted March 7, 2018 Report Share Posted March 7, 2018 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 Quote Link to comment Share on other sites More sharing options...
pgjacob Posted March 7, 2018 Author Report Share Posted March 7, 2018 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> Quote Link to comment Share on other sites More sharing options...
pgjacob Posted March 7, 2018 Author Report Share Posted March 7, 2018 Also... why do you add a "b" in front of the field picker value? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.