- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 02:33 PM
Hi,
I have a couple of variables on my catalog item that are of type Label.
i want to hide these 2 variables when a particular value is selected from a dropdown.
So i am wrote a script on the onchange event of the dropdown variable to hide labels but now it labels are always hidden. I want to display or hide them depeding on the value selected from the dropdown.
Here is the code.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
val = g_form.getValue('upl_documenttype');
if (val == "DD254" || val == "CSCS" || val == "CDCG");
{
g_form.setDisplay('upl_lblpop', false);
}
//Type appropriate comment here, and begin script below
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 02:36 PM
Updated code here.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
val = g_form.getValue('upl_documenttype');
if (val == "DD254" || val == "CSCS" || val == "CDCG");
{
g_form.setDisplay('upl_lblpop', false);
}
else
{
g_form.setDisplay('upl_lblpop', true);
}
//Type appropriate comment here, and begin script below
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 02:36 PM
Updated code here.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
val = g_form.getValue('upl_documenttype');
if (val == "DD254" || val == "CSCS" || val == "CDCG");
{
g_form.setDisplay('upl_lblpop', false);
}
else
{
g_form.setDisplay('upl_lblpop', true);
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 02:44 PM
I had added an else condition earlier but it gives a compilation error.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
val = g_form.getValue('upl_documenttype');
if (val == "DD254" || val == "CSCS" || val == "CDCG");
{
g_form.setDisplay('upl_lblpop', false);
}
else
{
g_form.setDisplay('upl_lblpop', true);
}
//Type appropriate comment here, and begin script below
}
Could not save record because of a compile error: JavaScript parse error at line (12) column (6) problem = syntax error (<refname>; line 12)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 02:45 PM
The reason is you have ; in your if condition i.e if (val == "DD254" || val == "CSCS" || val == "CDCG"); should be if (val == "DD254" || val == "CSCS" || val == "CDCG")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2017 02:39 PM
Hi Amol,
Add an else condition to make the label visible again
else
{
g_form.setDisplay('upl_lblpop', true);
}
Thanks,
Nitin.
Please Hit like, Helpful or Correct depending on the impact of the response