CA Service Management

  • 1.  Hide/enable field based on column layout selection

    Posted May 29, 2015 04:36 PM

    Hi,

     

    I tired to enable or disable text boxes based on selected value in the column layout. I have 2 values (A,B) and two text box (X,Y).

    I am using java script function to enable/disable the fields.


    If A selected it has to enables the 'X' text box. If B selected it has to enables X,Y text box. If i deselect B and I select A and B together it has to enable X,Y text boxes again. If none of the above selected all text boxes should get hidden


    I am executing the below java script code in the onchange.

     

    Code:

     

    ShowOrHideloc : function() {

    var selected = ca_fdGetSelectedOptionValues(ca_fd.formId, 'loc')[0];

    if (selected == 'A')

    {

      ca_fdShowField(ca_fd.formId, 'X');

      ca_fdHideField(ca_fd.formId, 'Y');

    }

     

    else if (selected == 'B')

    {

      ca_fdShowField(ca_fd.formId, 'X');

      ca_fdShowField(ca_fd.formId, 'Y');

    }


    else if (selected == 'A' && selected == 'B')

    {


    ca_fdShowField(ca_fd.formId, 'X');

    ca_fdShowField(ca_fd.formId, 'Y');

    }

    else

    {

    ca_fdHideField(ca_fd.formId, 'X');

    ca_fdHideField(ca_fd.formId, 'Y');

    }

    },

     

     

    I am facing issue on here where the If i deselect B and I select A and B together it has to enable X,Y text boxes but  it is not happening.




    Regards,

    Amala




  • 2.  Re: Hide/enable field based on column layout selection

    Posted May 29, 2015 07:37 PM

    The explanation of your requirement appears to be:

     

    If B is selected then show X and Y  (regardless of the setting of A)

    if B is not selected but A is selected show X hide Y

    if neither are selected hide X and Y

     

    So the condition should look like:

    if (selected == 'B')

    {

      ca_fdShowField(ca_fd.formId, 'X');

      ca_fdShowField(ca_fd.formId, 'Y');

    }

    else if (selected == 'A')

    {

      ca_fdShowField(ca_fd.formId, 'X');

      ca_fdHideField(ca_fd.formId, 'Y');

    }

    else

    {

    ca_fdHideField(ca_fd.formId, 'X');

    ca_fdHideField(ca_fd.formId, 'Y');

    }



  • 3.  Re: Hide/enable field based on column layout selection

    Posted Jun 01, 2015 11:54 AM

    Hi Lindsay,

     

    Thanks for the reply.

     

    How can i write a condition if both A & B selected together.

     

    This condition again should show both X & Y field together.

     

     

    Thanks,

    Amala



  • 4.  Re: Hide/enable field based on column layout selection

    Posted Jun 01, 2015 06:43 PM

    Do you really need to? Don't you want to show X & Y if B is selected? Why do you need a condition to check if B & A are both selected (to show X & Y) if selecting B alone will produce the same result (show X & Y)?

     

    This will work exactly the same as the first solution I proposed:

    if (selected == 'A' && selected == 'B')

    {

    ca_fdShowField(ca_fd.formId, 'X');

    ca_fdShowField(ca_fd.formId, 'Y');

    }

    else if (selected == 'B')

    {

      ca_fdShowField(ca_fd.formId, 'X');

      ca_fdShowField(ca_fd.formId, 'Y');

    }

    else if (selected == 'A')

    {

      ca_fdShowField(ca_fd.formId, 'X');

      ca_fdHideField(ca_fd.formId, 'Y');

    }

    else

    {

    ca_fdHideField(ca_fd.formId, 'X');

    ca_fdHideField(ca_fd.formId, 'Y');

    }



  • 5.  Re: Hide/enable field based on column layout selection

    Posted Jun 03, 2015 04:47 PM

    Hi Linda,

     

    It is working fine when only 1 option is selected based on the same JS function provided. However i am unable to take into account when more than 1 option is selected.

     

    I am using the below to get the selection.

     

    var selected = ca_fdGetSelectedOptionValues(ca_fd.formId, 'loc')[0];


    How i can achieve it.



    Thanks,

    Amala



  • 6.  Re: Hide/enable field based on column layout selection

    Posted Jun 03, 2015 06:14 PM

    Please call me Lindsay.

     

    The line:

    var selected = ca_fdGetSelectedOptionValues(ca_fd.formId, 'loc')[0];

    gets you only the first selection.


    This line:

    var selected = ca_fdGetSelectedOptionValues(ca_fd.formId, 'loc')[1];

    will get you the second selection.


    This line:

    var selected = ca_fdGetSelectedOptionValues(ca_fd.formId, 'loc');

    will get you all the selections but the var selected will be an array.