- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2016 01:43 PM
I have a simple client script that I want to run on a catalog item that I can't seem to figure out. Need your help!
I have a variable called "access_type" that is a multiple choice type. I want to have an onChange script to display a field message if the "network" option is selected. So I created this script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Shows field message if network is selected.
if(newValue + "" == "network" && oldValue != newValue){
g_form.showFieldMsg("access_type","This form is to request NEW access to network folders and files only.","info");
}
else{
g_form.hideFieldMsg("access_type",true);
}
}
The script works, but the problem I'm experiencing is if I click the "network" option multiple times even after it is already selected, another message pops up. I can't seem to figure out how to prevent multiple messages from appearing. Advice anyone??
Clicked "network" 3 times without choosing another option.
Thanks,
Johnny
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2016 01:49 PM
Johnny,
Change the script to always hide the field message first and then only add it back if the choice is set to network. Like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Shows field message if network is selected.
g_form.hideFieldMsg("access_type",true);
if(newValue + "" == "network" && oldValue != newValue){
g_form.showFieldMsg("access_type","This form is to request NEW access to network folders and files only.","info");
}
}
-Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2016 01:49 PM
Johnny,
Change the script to always hide the field message first and then only add it back if the choice is set to network. Like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Shows field message if network is selected.
g_form.hideFieldMsg("access_type",true);
if(newValue + "" == "network" && oldValue != newValue){
g_form.showFieldMsg("access_type","This form is to request NEW access to network folders and files only.","info");
}
}
-Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2016 01:51 PM
Hi Johny,
Replace if(newValue + "" == "network" && oldValue != newValue) with
Var net = g_form.getValue('your variable name');
If(net == 'network')
{
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 06:12 AM
Hi Pradeep,
Thanks for your advice, but this did not work. The behavior was the same after this update.
Regards,
Johnny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 06:10 AM
Thanks Steve! That worked.