TroubleShooter Posted February 10, 2019 Report Share Posted February 10, 2019 Hi, I was trying to implement Rules on a Submission Form DataPage and was trying to hide a Section with required fields. I was wondering why I can't do so until a Support person pointed out on an article that it is not possible to hide a Section if there are required fields inside it. I was wondering if there is something JavaScript can do with this. Thanks in advance. Regards, TroubleShooter Quote Link to comment Share on other sites More sharing options...
DefinitelyNot31337 Posted February 10, 2019 Report Share Posted February 10, 2019 Hi @TroubleShooter You can to paste>modify this code in the Footer of your Submission Form (disable HTML Editor). Virtual4 is a checkbox, but you may opt to use other field elements such as text fields. Just comment/uncomment the corresponding alternate lines. <script> var cbx = document.querySelector('[id*=cbParamVirtual4]') //var textbox = document.querySelector('[id*=InsertRecordmyField]') var tbl = document.querySelector('[id*=hideThisTable]') //textbox.onchange = function(){ cbx.onchange = function(){ //if (textbox.value == "hidemyfield") if (cbx.checked == false) tbl.style.display = "none"; else tbl.style.display = "block"; } var event = new Event('change'); cbx.dispatchEvent(event) </script> Next thing is to wrap all the fields you wish to hide in 2 HTML blocks (Remember to disable HTML Editor from the Advanced tab). *Note that it is able to span across sections. HTML Block 1: <table id="hideThisTable"> </table> =============== TL;DR / Preview Once your page loads, if you check/uncheck Virtual4, it should toggle showing/hiding what's sandwiched within the <table> tag. Hope this helps. Cheers! DN31337 Quote Link to comment Share on other sites More sharing options...
geoffdude Posted February 26, 2019 Report Share Posted February 26, 2019 First .. if you hide REQUIRED fields, then your form may never get submitted, as there could be a situation where they're not displayed. - That's why it's not something which is done. For your situation - the fix is super easy. (1) Create a checkbox/button in the form named "section2btn" or whatever you want (it can be virtual or part of your table) Example: Show More Questions: [ ] Yes (2) Below the above checkbox -> Create a section (example "SECTION2") with your specific form questions applied to it - the ones you wish to hide and have required. Example:SECTION2 -Q1 -Q2 -Q3 (3) Once you're done with all of your questions - make none of them required - then go back and select your check box above (named "section2btn") and create 2 rules for it. (3a) Create Rule #1 Example: Criteria "section2btn" is not checked Actions Make Section2 hidden (3b) Create Rule #2 Example: Criteria "section2btn" is checked Actions Make Q1 requiredMake Q2 requiredMake Q3 required That should work for you. Best, Geoff Quote Link to comment Share on other sites More sharing options...
RuisiHansamu Posted May 29, 2022 Report Share Posted May 29, 2022 Hi there, I wanted to share this workflow that might help anyone out. The logic here is just vice-versa, when a field is not checked then hide the field. Then if it is checked, the field will appear. 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.