Show Hide Section if the hidden field is True or False
Confluence User - 04 Dec, 2024
Hi all,
I have custom html where it check the total amount if the total is more than 1000(gtotalcur), it will put the value of hidden field(adVisible2) to "True" or "False". Using this hidden field value i would like to show hide a section. If the value is "True" then show the section if false then hide the section.
I am able to get the value to the hidden field but the show hide section does not seem to be working even though the hidden field is "True"
Custom HTMl
<script>
$(document).ready(function () {
console.log("DOM is ready");
// Selectors
var gtotalCur = $('#gtotalCur'); // Input field for total currency
var adVisibleField = $('#adVisible2'); // Hidden field for 'adVisible'
function toggleSection9() {
// Parse value, accounting for commas
var val = parseFloat(gtotalCur.val().replace(/,/g, '')) || 0;
if (val > 10000) {
adVisibleField.val("True"); // Set adVisible to true
console.log("''adVisible' set to true");
} else {
adVisibleField.val("False"); // Set adVisible to false
console.log("''adVisible' set to false");
}
}
// Ensure initial setup
toggleSection9();
// Monitor changes in 'gtotalCur'
gtotalCur.on('input change', function () {
toggleSection9();
});
});
</script>
forms
