Cheeseybud Posted July 22 Report Share Posted July 22 Hi all, I have a datapage with a field for worked hours and a checkbox (hidden) for Approved (true/false). This will go to admin for approval. Basically, I want the checkbox to auto select (true) on submission if the Worked hours field is <= 50 but false if the worked hours is >= 50. I have tried numerous scripts, including some given from support, but I just cannot get it to work. Any help would be greatly appretiated. Thanks Quote Link to comment Share on other sites More sharing options...
0 CoopperBackpack Posted July 23 Report Share Posted July 23 Hello @Cheeseybud, This code should work for the Submission form. If the DataPage type differs, please update this thread and provide the DataPage type (it can be Details DataPage, Inline Add option on Tabular Report). Add this code to the Footer of the Submission form, disable the HTML editor on the Advanced tab before passing the code, and change the field names in the code if needed. <script> document.addEventListener('DataPageReady', checkboxHandler); function checkboxHandler(){ const hoursField = document.querySelector('#InsertRecordWorked_hours'); //use your field name instead of Worked_hours const approvedField = document.querySelector('#InsertRecordApproved'); //use your field name instead of Approved hoursField.addEventListener('change', (event) =>{ let hoursValue = parseFloat(event.target.value); if(hoursValue <= 50){ approvedField.value = 'Y'; } else{ approvedField.value = ''; } }) document.removeEventListener('DataPageReady', checkboxHandler); } </script> It is easier to check the Yes/No field by Trigger on record insert. But this works if Triggers are available in your plan. Quote Link to comment Share on other sites More sharing options...
Question
Cheeseybud
Hi all,
I have a datapage with a field for worked hours and a checkbox (hidden) for Approved (true/false). This will go to admin for approval.
Basically, I want the checkbox to auto select (true) on submission if the Worked hours field is <= 50 but false if the worked hours is >= 50.
I have tried numerous scripts, including some given from support, but I just cannot get it to work.
Any help would be greatly appretiated.
Thanks
Link to comment
Share on other sites
1 answer to this question
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.