Help needed with dropdown values in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 02:57 AM
I have a dropdown with some values. I want to show different values based on the type of type.
If user choose type as India, show 3 values in dependant dropdown.
If user choose type as Onsite, show 2 values in dependant dropdown .
How to hide and show based on the selection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 03:01 AM - edited 08-16-2023 03:13 AM
Hello @Snehal13
You need to write a onChange Client Script :-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var loc= g_form.getValue('fieldname');
if(loc == 'India'){
g_form.clearOptions(<fieldName>);
g_form.addOption(<fieldName>, <choiceValue>, <choiceLabel>, <targetIndex>);
g_form.addOption(<fieldName>, <choiceValue>, <choiceLabel>, <targetIndex>);
g_form.addOption(<fieldName>, <choiceValue>, <choiceLabel>, <targetIndex>);
}
if(loc == 'Onsite){
g_form.clearOptions(<fieldName>);
g_form.addOption(<fieldName>, <choiceValue>, <choiceLabel>, <targetIndex>);
g_form.addOption(<fieldName>, <choiceValue>, <choiceLabel>, <targetIndex>);
}
}
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 03:07 AM
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var a = g_form.getValue('u_choice_1');
if (a == 'jharkhand') {
g_form.clearOptions('u_choice_3');
g_form.addOption('u_choice_3', 'ranchi', 'Ranchi');
g_form.addOption('u_choice_3', 'deoghar', 'Deoghar');
}
if (a == 'karnataka') {
g_form.clearOptions('u_choice_3');
g_form.addOption('u_choice_3', 'bangalore', 'Bangalore');
g_form.addOption('u_choice_3', 'mysore', 'Mysore');
}
if (a == 'maharastra') {
g_form.clearOptions('u_choice_3');
g_form.addOption('u_choice_3', 'pune', 'Pune');
g_form.addOption('u_choice_3', 'mumbai', 'Mumbai');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 11:35 AM
Hello @Snehal13
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful and close the thread.
Regards,
Samaksh