- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 04:35 AM - edited 10-12-2023 04:36 AM
Hi all,
I have a requirement where on a CI if a user chooses mutligrain bread, they shouldn't be able to pick a strawberry smoothie.
I have an onChange client script that hides the option. I have tried setReadOnly, setVisible, removeOption and all successfully remove the option, however, if the user changes their mind and then clicks on white bread, the strawberry smoothie option doesn't reappear.
How would I go about implementing this? Is the onChange client script in the right direction or is that completely wrong?
Any help would be much appreciated.
Kind regards,
G
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 04:46 AM
could you please try below code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'multigrain') {
g_form.setVisible('strawberry_smoothie',false);
g_form.setVisible('blueberry_smoothie',false);
}
if(newValue == 'white bread') {
g_form.setVisible('strawberry_smoothie',true);
g_form.setVisible('blueberry_smoothie',true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 04:47 AM
Hi there,
Managed to solve this with the help of @chaudharymahesh
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'multigrain') {
g_form.setVisible('strawberry_smoothie',false);
g_form.setVisible('blueberry_smoothie',false);
}
if (newValue != 'multigrain'){
g_form.setVisible('strawberry_smoothie', true);
g_form.setVisible('blueberry_smoothie',true);
}
}
Hope this helps someone!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 04:39 AM
do you have the logic to show fields in else part in your client script. if possible, could you share your client script code here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 04:43 AM
This is what I have in my script so far:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'multigrain') {
g_form.setVisible('strawberry_smoothie',false);
g_form.setVisible('blueberry_smoothie',false);
}
}
Should I add an else loop to then switch it back?
Kind regards,
G
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 04:46 AM
could you please try below code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'multigrain') {
g_form.setVisible('strawberry_smoothie',false);
g_form.setVisible('blueberry_smoothie',false);
}
if(newValue == 'white bread') {
g_form.setVisible('strawberry_smoothie',true);
g_form.setVisible('blueberry_smoothie',true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 04:45 AM
Your comment really helped and I have just implemented an else loop in the script, thank you so much!
Kind regards,
G