Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
JavaScript
function onChange(control, oldValue, newValue, isLoading) 
{
   if (isLoading || newValue == '') {
      return;
   }

   switch(newValue) {

        case 4:
            alert(newValue);
     /*        g_form.setDisplay('DLP_Scan',false);
            g_form.setDisplay('account_requesting',false);
            g_form.setDisplay('rule_change',false);
            g_form.setDisplay('report_requesting',false);
            g_form.setDisplay('change_need',true);*/

            break;

    case 2:
            alert(newValue);
        g_form.setDisplay('DLP_Scan',false);
            g_form.setDisplay('change_need',false);
            g_form.setDisplay('rule_change',false);
            g_form.setDisplay('report_requesting',false);
            g_form.setDisplay('account_requesting',true);
        break;
    case 5:
            alert(newValue);
        g_form.setDisplay('DLP_Scan',false);
            g_form.setDisplay('change_need',false);
            g_form.setDisplay('account_requesting',false);
            g_form.setDisplay('report_requesting',false);
            g_form.setDisplay('rule_change',true);
        break;
            case 3:
            alert(newValue);
        g_form.setDisplay('DLP_Scan',false);
            g_form.setDisplay('change_need',false);
            g_form.setDisplay('account_requesting',false);
            g_form.setDisplay('rule_change',false);
            g_form.setDisplay('report_requesting',true);
        break;
            case 6:
            alert(newValue);
        g_form.setDisplay('account_requesting',false);
            g_form.setDisplay('change_need',false);
            g_form.setDisplay('rule_change',false);
            g_form.setDisplay('report_requesting',false);
            g_form.setDisplay('DLP_Scan',true);
        break;

    }
    //Type appropriate comment here, and begin script below

    }
Posted
Updated 6-Apr-15 22:19pm
v2
Comments
Afzaal Ahmad Zeeshan 7-Apr-15 4:17am    
Why is it not working?
ajitdstar4u 7-Apr-15 4:25am    
i checked the syntax, it is correct but still it is not working.
is anything wrong about it. i guess it is not due to proper numbering of case like first we have to write for case 1 then for case to etc . any help will be much appreciated.
Afzaal Ahmad Zeeshan 7-Apr-15 4:28am    
You should check the console in that case. It would help you.
OriginalGriff 7-Apr-15 4:31am    
So how do you know it's not working?
How are you calling it?
How are you testing it?
What does it do that you didn't expect, or not do that you did?
ajitdstar4u 7-Apr-15 5:29am    
if the case statement execute the in UI some fields like g_form.setdisplay('DLP_Scan', true) should enable but it is not.

1 solution

Variable newValue probably contains string.
The cases should be in quotes.
So your cases would be
JavaScript
 case '4':
    g_form.setDisplay('DLP_Scan',false);
    g_form.setDisplay('account_requesting',false);
    g_form.setDisplay('rule_change',false);
    g_form.setDisplay('report_requesting',false);
    g_form.setDisplay('change_need',true);
    break;
 case '2':
    alert(newValue);
g_form.setDisplay('DLP_Scan',false);
    g_form.setDisplay('change_need',false);
    g_form.setDisplay('rule_change',false);
    g_form.setDisplay('report_requesting',false);
    g_form.setDisplay('account_requesting',true);
break;


Vice versa you could convert newValue to integer.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900