Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Instead of toggling visibility of the section9, i suggest to move the content of section9 in a <template> element and leave section9 empty initially.
when gtotalCur >=
10000,
clone the content of section9 from <template> tag into section9's <div> element
and when gtotalCur <
10000, remove the content of section9.
Example for js:
<script> $(document).ready(function() { var section = $('#section9'); function removeMandatory() { section.empty(); } function addMandatory() { template = $("#myInputs").clone(); section.append(template); } // remaining codes remains the same }); </script>
Example for html:
<template id="myInputs"> <input type="text"> <select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> <textarea> Awesome, you did it! </textarea> </template>
Thank you for your reply.
do you have any example which i can study to understand?
Hi.. just drop you with an example above, have a try!
Hi.. thanks for your reply and example.. i have tired putting this into a single Custom HTML field but it seem like its not working. I'm i doing something wrong?
<script> $(document).ready(function() { var section = $('#section9'); function removeMandatory() { section.empty(); } function addMandatory() { template = $("#myInputs").clone(); section.append(template); } // remaining codes remains the same // Function to check gtotalCur and toggle section visibility function checkSectionVisibility() { var gtotalCur = parseFloat($('input[name="gtotalCur"]').val().replace(/,/g, '')) || 0; if (gtotalCur >= 10000) { //$('#section9').show(); // Show section9 if gtotalCur >= 10000 addMandatory(); // Add mandatory attributes back } else { //$('#section9').hide(); // Hide section9 if gtotalCur < 10000 removeMandatory(); // Remove mandatory attributes } } // Initial check on page load checkSectionVisibility(); // Listen for changes on gtotalCur input field $('input[name="gtotalCur"]').on('input change', function() { checkSectionVisibility(); }); }); </script> <template id="myInputs"> <input type="text"> <select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> <textarea> Awesome, you did it! </textarea> </template>
Hi, i suppose a working sample is more beneficial for you.
Make sure do not set Validator for any inputs you have in Section9, just leave it empty.
Hope you like it: APP_sample-for-dx7.jwa
Hi thank you for the sample. seem to be working now.
one more related question is it possible to convert this select box to a popup select box and the data is taken from the datalist?
I was wondering if there is a way to set a field to "Mandatory" if the section is visible. This needs to be set before any submission occurs, so I think the only way is to use custom HTML.
The built-in visibility control for DX7 cannot be set because it does not support the relational operator(greater than or less than), so I managed to create a custom HTML to show the hide section. Because this was done via custom, if a submission was done without the section visible, it shows "Validation Error." If I remove this mandatory checkbox, then the submission was successful.
Below is my custom HTML code. "Section 9" is the section that shows hide; within this section there is a select box field, which I wish to set to mandatory if visible via vice versa.
Thank you in advance