Hide fields based off selected from a dropdown. Cases

Hi


I have the need to hide a number of fields based off what is selected from a drop down list on a field in the same screen.


i've used a bit of Java that works in the Onchange script:

if(Values('case_productarea')=='QC29')

{

hidden = true;

}

else

{

hidden = false;

}

This works but only once the record is saved, the fields i've put the script on disappear but they dont disappear once the needed dropdown value is selected.

Anyhelp with this Java is appreciated.

Thanks

  • 0

    Try something like this in the OnChange script of case_productarea:

    if (this.value != 'QC29')

    {

    document.getElementById('case_NameOfFieldToHideGoesHere').style.visibility='Hidden'

    document.getElementById('_Captcase_NameOfFieldToHideGoesHere').style.visibility='Hidden'

    }

    else

    {

    document.getElementById('case_NameOfFieldToHideGoesHere').style.visibility='Visible'

    document.getElementById('_Captcase_NameOfFieldToHideGoesHere').style.visibility='Visible'

    }

    This script should dynamically hide a different field when you change the value in case_productarea.

    This is valid for v6.2, and should work through versions up to v7.1. v7.2 has the new client-side API, which has some different ways of dealing with hiding objects.

    To keep them hidden after you've saved the record, put the code that you posted above in the CreateScript of the fields you want to keep hidden.

    - Matt -

  • 0

    Hi, thanks for that unfortunatly it still only hides the fields once the record has been saved. The field remains when selecting a value from the drop down.

    Karl

  • 0

    Oh apologies it seemed i still had some code on that field i was trying to hide, seems to work well thanks!

    Now if i want to do it again for another value in the dropdown, do i just put another chunk of code in the same on change script but start with (this.value != 'CSA')

  • 0

    Usually you need to combine alternate conditions into an if...else if...else statement:

    if (condition1)

    {

    code to be executed if condition1 is true

    }

    else if (condition2)

    {

    code to be executed if condition2 is true

    }

    else

    {

    code to be executed if neither condition1 nor condition2 is true

    }

    If you need to trigger the same event for multiple conditions, you can use the | symbol to create an OR statement:

    if (this.value == 'QC29' | this.value == 'QC30' | this.value == 'QC31')

    {

    Stuff Happens

    }

    I recommend performing an internet search for some of these JavaScript basics to get a better feel for them before you get too complex.

    - Matt -