UltraSrc Posted January 19, 2017 Report Share Posted January 19, 2017 The code below works fine when someone changes the default value from No to Yes in my 'DispoToday' field. My challenge is when the record already has a value of Yes and someone updates another field then the script will update the date again. I only want the date to write out the first time someone changes the 'DispoToday' from No to Yes. <script type= "text/javascript"> function getT() { if(document.getElementById("EditRecordDispoToday").value == 'Yes') { document.getElementById("EditRecordTimeofView").value = '[@cb:Timestamp]'; } } document.getElementById("caspioform").onsubmit = getT; </script> Quote Link to comment Share on other sites More sharing options...
Mathilda Posted January 26, 2017 Report Share Posted January 26, 2017 On 1/19/2017 at 7:29 PM, UltraSrc said: The code below works fine when someone changes the default value from No to Yes in my 'DispoToday' field. My challenge is when the record already has a value of Yes and someone updates another field then the script will update the date again. I only want the date to write out the first time someone changes the 'DispoToday' from No to Yes. <script type= "text/javascript"> function getT() { if(document.getElementById("EditRecordDispoToday").value == 'Yes') { document.getElementById("EditRecordTimeofView").value = '[@cb:Timestamp]'; } } document.getElementById("caspioform").onsubmit = getT; </script> Try changing the last line of code. Use: document.getElementById("EditRecordDispoToday").onchange = getT; instead of: document.getElementById("caspioform").onsubmit = getT; Another option is to create a rule. The rule will be: when DispoToday field equal to Yes - make TimeofView field display only Hope that helps Cheers! UltraSrc 1 Quote Link to comment Share on other sites More sharing options...
UltraSrc Posted January 30, 2017 Author Report Share Posted January 30, 2017 On 1/26/2017 at 3:04 AM, Mathilda said: Try changing the last line of code. Use: document.getElementById("EditRecordDispoToday").onchange = getT; instead of: document.getElementById("caspioform").onsubmit = getT; Another option is to create a rule. The rule will be: when DispoToday field equal to Yes - make TimeofView field display only Hope that helps Cheers! Thank you - changing the last line of the code has worked out. Much appreciated it. Quote Link to comment Share on other sites More sharing options...
Mathilda Posted January 31, 2017 Report Share Posted January 31, 2017 14 hours ago, UltraSrc said: Thank you - changing the last line of the code has worked out. Much appreciated it. You're welcome! 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.