- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2018 06:44 AM
Hi,
I am using a client script to populate the choice options using below code.
g_form.clearOptions("reason");
g_form.addOption("reason", "", "Please Select One");
for (index = 0; index < newJSOnObject.length; ++index)
{
g_form.addOption("reason", newJSOnObject[index].ReasonCode, newJSOnObject[index].Reason);
}
g_form.setValue("reason", "10");
I need to set the selected value of this choice field and I tried to use g_form.setvalue to set the default selected value of choice option but it did not work.
I would appreciate if anyone can help me on this.
Thanks for the help!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2018 06:57 AM
That should work as long as you have a string value of "10" as an option for that field. You might try setting up a client script to output that value (and its type) and see if it all matches.
alert(g_form.getValue("reason") + " : " + typeof(g_form.getValue("reason"));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2018 06:57 AM
That should work as long as you have a string value of "10" as an option for that field. You might try setting up a client script to output that value (and its type) and see if it all matches.
alert(g_form.getValue("reason") + " : " + typeof(g_form.getValue("reason"));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2018 10:19 AM
Just checking on on this one. Has this question been answered or is there more information I can help you with? If it's been answered, please mark the answer above as the correct one so people know this has been taken care of. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2018 11:29 AM
Yes Mark, this is helpful. Thank you!