how to show hide info messages depending on choice value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 02:24 PM
Hi All,
I have three choices B, C & L depending on which the user selects I like to show an info message for that choice and hide the others if the choice changes. currently only the choice L will display and if I rem out the hide fields the show fields will display when choice changes but obviously doesn't hide the other info messages. can anyone help with this as I'm fairly new to scripting. Am I missing something obvious???
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '')
return;
var choiceValue = g_form.getValue('fieldname');
if (choiceValue == 'b'){
g_form.showFieldMsg('fieldname', 'B for Broadcast', 'info');
g_form.hideFieldMsg('fieldname', 'C for Cyclical ', 'info');
g_form.hideFieldMsg('fieldname', 'L for Linear', 'info');
}
else
if (choiceValue == 'c'){
g_form.hideFieldMsg('fieldname', 'B for Broadcast', 'info');
g_form.showFieldMsg('fieldname', 'C for Cyclical ', 'info');
g_form.hideFieldMsg('fieldname', 'L for Linear', 'info');
}
else
if (choiceValue == 'l'){
g_form.hideFieldMsg('fieldname', 'B for Broadcast', 'info');
g_form.hideFieldMsg('fieldname', 'C for Cyclical ', 'info');
g_form.showFieldMsg('fieldname', 'L for Linear', 'info');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 02:49 PM
Hi Nicky,
You only have to do a hideFieldMsg() once. I'd do it at the beginning to clear out any/all messages on that field. Something like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '')
return;
var choiceValue = g_form.getValue('fieldname');
if (choiceValue == 'b'){
g_form.hideFieldMsg('fieldname', true);
g_form.showFieldMsg('fieldname', 'B for Broadcast', 'info');
}
else
if (choiceValue == 'c'){
g_form.hideFieldMsg('fieldname', true);
g_form.showFieldMsg('fieldname', 'C for Cyclical ', 'info');
}
else
if (choiceValue == 'l'){
g_form.hideFieldMsg('fieldname', true);
g_form.showFieldMsg('fieldname', 'L for Linear', 'info');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 03:08 PM
you star thanks very much that works a treat, I've been on that for a long time.......

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 03:14 PM
Glad you like it. Don't forget to mark this as correct in case someone else is looking for a similar solution. 🙂