Ui script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 12:07 PM
create a ui script
task State>>Mumbai,Delhi,Uttar Pradesh
City>>Juhu,Bandra,Dadar,Okhla,Jafrabad,Cp,Lucknow,fatehpur,kanpur
when we select state=mumbai then,
city=juhu,bandra,dadar
when we select state=delhi then,
city=Okhla,Jafrabad,Cp
when we select state=Uttar Pradesh then,
city=Lucknow,fatehpur,kanpur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 06:02 PM - edited 11-15-2023 06:03 PM
HI @Affanahmadd ,
Where are you using these two select box based field, how are you adding state field values, are you using choice [ sys_chocie ] table or Question Choice table [ question_choice].
you can refer the category & sub-category mapping logic from incident form where category and sub-category defined over sys_choice table with dependency. In this case, every city has a state value as dependent.
refer this for sample
refer for sample UI script
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 08:43 PM
HI @Affanahmadd ,
I trust you are doing great.
Please find the below code for the same
function updateCityOptions(state) {
var cityField = g_form.getReference('city'); // Replace 'city' with the actual field name
cityField.options.length = 0; // Clear existing options
var cities = {
'Mumbai': ['Juhu', 'Bandra', 'Dadar'],
'Delhi': ['Okhla', 'Jafrabad', 'Cp'],
'Uttar Pradesh': ['Lucknow', 'Fatehpur', 'Kanpur']
};
if (cities[state]) {
cities[state].forEach(function(city) {
var opt = document.createElement('option');
opt.value = city;
opt.innerHTML = city;
cityField.appendChild(opt);
});
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi