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

Clear variable values based on another variable choice selection

Hema koneti
Giga Expert

I have a Variable with 3 choices:

1. choice A
2. choice B
3. choice C

and I have 3 other variables source, ip, port. Now, clear the values of those variables
whenever the choice variable value changes.

 

Anyone help me to do this..

1 ACCEPTED SOLUTION

Aditya02
Tera Guru

Hi @Hema koneti ,

 

You can achieve this by writing a onchange Client script, Here is the script which helps to solve your problem:

 

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '' ) {
      return;
   }
    // this Onchange() client script should be written on the variable having 3 choices.

    g_form.clearValue('variable_name');    // source
    g_form.clearValue('variable_name');    // IP
    g_form.clearValue('variable_name');    // port
}

 

 

To assist others (or for me to help you more effectively), please click "Accept as Solution" and/or give Kudos.

Thanks, Aditya

View solution in original post

3 REPLIES 3

vishakhayadav24
Tera Guru

@Hema koneti 

Whenever you are selecting the choice variable just write a on change script  below 

if(newValue == ''|| newValue != oldValue)
{
g_form.clearValue('ip');// pass your variable name
g_form.clearValue('source');
g_form.clearValue('port');
}
 

Robbie
Kilo Patron
Kilo Patron

Hi @Hema koneti,

 

This can easily be achieved with an onChange catalog Client Script.

 

Create an onChange Script, make sure you select the type onChange, and make sure you associate it with the Choice field which can change:

 

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '' ) {
      return;
   }
 
    if (newValue != oldValue) {
        g_form.clearValue('your_source_field_name');
        g_form.clearValue('your_ip_field_name');
        g_form.clearValue('your_port_field_name');
    }
}

 

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie

Aditya02
Tera Guru

Hi @Hema koneti ,

 

You can achieve this by writing a onchange Client script, Here is the script which helps to solve your problem:

 

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '' ) {
      return;
   }
    // this Onchange() client script should be written on the variable having 3 choices.

    g_form.clearValue('variable_name');    // source
    g_form.clearValue('variable_name');    // IP
    g_form.clearValue('variable_name');    // port
}

 

 

To assist others (or for me to help you more effectively), please click "Accept as Solution" and/or give Kudos.

Thanks, Aditya