Onchange client script to set value on hidden variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:57 AM
Hi,
I have a hidden field in a form that I need to set value on. Is this possible with on change script?
If variable A has answer "no" then variable B is not visible. But variable B should then be set to "abc".
So can I use on change client script to set value on this hidden variable? I tried but got "Javascript error in your browser console".
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 02:09 AM
Hi,
You can try to make the field visible, set the value and then hide it again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 02:10 AM - edited 12-07-2023 04:02 AM
Hello @CE_,
Yes, this is possible.
Just you have to set variable B to "abc" before making the field hidden.
I tired this in my instance:-
Regards,
Prashant Ahire
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 02:13 AM
Hi @CE_ ,
Hope you are using UI policy to do this? If variable A has answer "no" then variable B is not visible
if Yes then in the UI policy itself u can mention under script tab if condition is true then
g_form.setValue('B','abc');
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 02:29 AM
Hi @CE_
If you've hidden your variable by enabling the Hidden checkbox, you can still set its value using the following code:
g_form.setValue('<variable_name>', '<value>');
The error in your browser console might be due to other causes. Can you share what you have done so far?
Cheers,
Tai Vu