wgalliance Posted August 8, 2016 Report Share Posted August 8, 2016 I have a checkbox field "AppLocked" that when checked I would like the submit/update button to be disabled (or hidden) and for their to be an alert that says "Your application is locked from edits. To submit any changes please contact your federation manager." Is there a simple code I can use for this purpose? Quote Link to comment Share on other sites More sharing options...
JayMont Posted August 9, 2016 Report Share Posted August 9, 2016 No need to code in JS for this one. You can use Conditional Forms if your DataPage is a submission, search, single record update, or details page. Read more here: http://howto.caspio.com/datapages/forms/conditional-forms/ Quote Link to comment Share on other sites More sharing options...
wgalliance Posted August 9, 2016 Author Report Share Posted August 9, 2016 In some cases this would work, but in many of my datapages I already have rules and conditions applied that do not allow me to to then disable fields. For the first time a user access the datapage, I have rules that set required fields, hide sections, etc. However, once they submit the page, a checkbox changes to "submitted" when that field is checked, if the user goes back to look at their information, I want to disable the ability for them to submit NEW changes to the datapage. I want to lock it from any further changes. Thus I do need JS because I cannot use the disable the fields in the rules section since they are already being used for other conditions. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted August 9, 2016 Report Share Posted August 9, 2016 You can have this code in Footer of your update page: <script> if (document.getElementById('EditRecordApproved').checked){ document.getElementById('Mod0EditRecord').style.display="none"; } </script><script> if (document.getElementById('EditRecordApproved').checked){ document.getElementById('Mod0EditRecord').style.display="none"; } </script> <script> if (document.getElementById('EditRecordCHECKBOXFIELDNAME').checked){ document.getElementById('Mod0EditRecord').style.display="none"; } </script> Replace CHECKBOXFIELDNAME with the actual field name aam82 1 Quote Link to comment Share on other sites More sharing options...
wgalliance Posted August 12, 2016 Author Report Share Posted August 12, 2016 PERFECT! Just what I needed. Quote Link to comment Share on other sites More sharing options...
wgalliance Posted September 9, 2016 Author Report Share Posted September 9, 2016 Hi MayMusic, I have had this script working on my pages for a while now. I recently changed some of my workflow so that the webpages now include a navigation menu that is a datapage in and of itself. This has made some of the script stop working. I've used this tutorial recommended by support to help me troubleshoot some issues. How can I rewrite this simple script which had been working prior to deploying a second datapage: <script> if (document.getElementById('EditRecordAppLocked').checked){ document.getElementById('Mod0EditRecord').style.display="none"; } </script> Any thoughts about how to use this with an .onload function that can then call the correct datapage by adding document.forms[1].onload to the script.... Quote Link to comment Share on other sites More sharing options...
MayMusic Posted September 9, 2016 Report Share Posted September 9, 2016 I need to take a look at the web page and inspect the code on your web page to see what is causing the issue. Can you give me the link to the page? Quote Link to comment Share on other sites More sharing options...
wgalliance Posted September 12, 2016 Author Report Share Posted September 12, 2016 I sent you a message with login details. Thanks! Quote Link to comment Share on other sites More sharing options...
wgalliance Posted September 13, 2016 Author Report Share Posted September 13, 2016 I ended up fixing this with another method. I hid the button in the style and then created my own button that could be hidden with a rule. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted September 16, 2016 Report Share Posted September 16, 2016 Sorry just saw your message when you have more than one page deployed on a web page, all the IDs are going to be the same for buttons and the rest so when you refer to an ID it only picks the very first one. Same thing for the DataPage itself. If you are referring to a DataPage you need to add Header/Footer and create an ID for the page Header: <div id="myPage"> Footer: </div> And then in your code for instance if you have document.getElementById('caspiofrom') you can use: document.getElementById('myPage') Quote Link to comment Share on other sites More sharing options...
IamNatoyThatLovesYou Posted March 29 Report Share Posted March 29 Hello Every one, Just providing an additional code here as well. When the submit button is hidden, the values will still be submitted when you hit the enter key. Below is a code to disable it. <script> document.addEventListener('BeforeFormSubmit', function(event) { event.preventDefault(); }); </script> Quote Link to comment Share on other sites More sharing options...
Kronos Posted April 7 Report Share Posted April 7 Hi, You can also hide or disable the update the update button in the Details page from this forum thread: 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.