- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 10:48 PM
Hi Experts
i have a issue please
options = is the onchange variable
the first if statements evaluates as expected, the second else if does nothing, that is it does not display the field altogether
Thanks
Levino
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearOptions('options');
var hours = g_form.getValue('contracted_hours');
if (hours <= 29) {
g_form.addOption('options', '', 'None');
g_form.addOption('options', 'Self-paced learning with support from team & Capability', 'Self-paced learning with support from team & Capability (Ideal for part timers or a return advisor)');
g_form.addOption('options', 'Full time Facilitated Onboarding (Committed for 40 hours a week for 5 weeks)', 'Full time Facilitated Onboarding (Committed for 40 hours a week for 5 weeks)');
} else if(hours >= 30) {
g_form.removeOption('options', 'Self-paced learning with support from team & Capability');
}
}
//Type appropriate comment here, and begin script below
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 11:07 PM - edited 02-12-2024 11:07 PM
I see it functioning correctly though.
Do you have any UI policy or script running to hide the visibility of the field on this item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 10:59 PM
Try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.clearOptions('options');
return;
}
var hours = g_form.getValue('contracted_hours');
if (newValue <= 29) {
g_form.addOption('options', '', 'None');
g_form.addOption('options', 'Self-paced learning with support from team & Capability', 'Self-paced learning with support from team & Capability (Ideal for part timers or a return advisor)');
g_form.addOption('options', 'Full time Facilitated Onboarding (Committed for 40 hours a week for 5 weeks)', 'Full time Facilitated Onboarding (Committed for 40 hours a week for 5 weeks)');
} else if (newValue >= 30) {
alert('test')
g_form.removeOption('options', 'Self-paced learning with support from team & Capability');
}
}
//Type appropriate comment here, and begin script below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 11:04 PM
hi
i have tried , the second if does evaluate that is i get the test alert, but the field does not get displayed
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 11:07 PM - edited 02-12-2024 11:07 PM
I see it functioning correctly though.
Do you have any UI policy or script running to hide the visibility of the field on this item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 11:09 PM
You are using client script to populate options. If it goes inside if loop then you are adding options but in else if you are removing option which is not available in variable choice list.
In else part you don't want any choice value? If this is so then it will show empty field only.
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Dhanu