Help with a ClientScript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 11:55 AM
Hi Guys,
I'm working on this script and it's working except for ONE scenario. This is a OnChange client script.
I have two folders, subfolder (parent) and subfolder_options (child). Latter appears only when a selection has been made to its parent folder, subfolder. Most of the time, child folder has select box values but when there's none, I wrote this script to hide the box altogether.
Problem is if I select a subfolder with no subfolder option, child folder goes away but I select a subfolder with 1 or more options, field does not come back.
function onChange(control, oldValue, newValue, isLoading) {
var selectBox = g_form.getControl('subfolder_options');
if (selectBox) {
// Check if the select box has no options (excluding the placeholder)
if (selectBox.options.length <= 1) {
// Make the field non-mandatory
g_form.setMandatory('subfolder_options', false);
g_form.setDisplay('subfolder_options', false);
}
else {
g_form.setMandatory('subfolder_options', true);
g_form.setDisplay('subfolder_options', true);
}
}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 12:30 PM
Hi @Sam10 ,
Here i am confused you have created a onchange client script is it on subfolder ? and in the 'if' you are checking the subfolder_option length if it is less than 1 you are hiding the subfolder_option so when you hide the field it will be 'none' so when you change anything in subfolder it doesn't matter because the 'if' condition will be satisfied so untill you refresh the page the field will not appear so change the 'if' condition ,
and let me know the exact requirement i might be able to help you, like based on which choice in Subfolder(parent) you want to hide the Subfolder_option field.
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang