- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 11:29 PM
Hello Team, We have a requirement to show free text fields based on the number entered on the quantity field, for example if user enter 3 in the quantity field 3 text fields should be visible if 5 is the quantity 5 text fields should be visible is there away to achieve this?
Thanks,
Prudhvi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 11:36 PM
Hello @Prudhvi Raj4
You can use onChange Client Script :-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var value=g_form.getValue('quantity');
for(let i=0; i<value; i++){
// code to visible the fields
}
}
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-13-2023 11:36 PM
Hello @Prudhvi Raj4
You can use onChange Client Script :-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var value=g_form.getValue('quantity');
for(let i=0; i<value; i++){
// code to visible the fields
}
}
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-13-2023 11:43 PM
Hi Prudhvi, this is what UI policies are made for. You can set visibility of fields based on conditions of other fields. See the documentation here to get started on that.
If you think my answer put you in the right direction or you appreciated my effort, please mark the response as Helpful (👍 ) or mark my response as Correct (✅).
Thanks in advance! Good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 11:46 PM
Hello @Prudhvi Raj4 ,
You can do one thing .
Store the backend names of the text fields in an array and loop the array based on the number entered in the quantity field in an on change client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var txt_Arr = ['text_field_1' , 'text_field_2','text_field_3' ,'text_field_4' ,'text_field_5'];
var qnt = parseInt(g_form.getValue('quantity_field_backend_name')); // just in case if the quantity field is string ,converting it to integer
for(vari=0; i<qnt; i++)
{
g_form.setVisible(txt_Arr[i],true);
}
}
Hope this helps
Mark my answer correct if this helps you
Thanks