The CreatorCon Call for Content is officially open! Get started here.

onchange client script reverse

gvramanarao
Giga Contributor

I'm writing client script -

my requirement is simple: if the category is 'software' then make 'description' field hidden. It is working fine, but I want to write reverse if, and I stuck there! When Im changing the category to some other, the description field is not visible. 

1 REPLY 1

palanikumar
Giga Sage
Giga Sage

Hi,

I suggest you to use UI Policy for this

Condition = category = software

UI Policy Action:

Add entry for Description and set visible to true

 

Note: UI Policy will reverse automatically

 

If you are using Client Script, then it should be a onChange Client script on variable category.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    if (newValue == "software") {
        g_form.setVisible("description", false);
    } else {
        g_form.setVisible("description", true);
    }

}
Thank you,
Palani