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

on changing choice, checkbox should automatically uncheck

prabhmeet
Giga Expert

Hi,

I have created a catalog item, it has a selectbox variable with 4 choices, I want that whenever I change the choices, the Checkboxes variables I have made (Menu and function)  should uncheck.

 

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

if(newValue == 'true'){
g_form.setValue('menu', false);
g_form.setValue('function',false);

}}

 

 

 

1 ACCEPTED SOLUTION

If you want it to be unchecked when ever the choice is changed remove the if condition

 

 

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

 

g_form.setValue('menu',false);

g_form.setValue('function',false);


}

 

and if you want to it to be unchecked only if a patricular choice is selected use the below code

 

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

var c=g_form.getValue('contact_type');// replace the 'contact_type' with your field name

if(c=='')// enter the choice which you want to trigger

{

g_form.setValue('menu',false);

g_form.setValue('function',false);

}
}

View solution in original post

9 REPLIES 9

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

var c=g_form.getValue('contact_type');// replace the 'contact_type' with your field name

if(c=='')// enter the choice which you want to trigger

{

g_form.setValue('menu',false);

g_form.setValue('function',false);

}
}}

Try this

If you want it to be unchecked when ever the choice is changed remove the if condition

 

 

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

 

g_form.setValue('menu',false);

g_form.setValue('function',false);


}

 

and if you want to it to be unchecked only if a patricular choice is selected use the below code

 

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

var c=g_form.getValue('contact_type');// replace the 'contact_type' with your field name

if(c=='')// enter the choice which you want to trigger

{

g_form.setValue('menu',false);

g_form.setValue('function',false);

}
}

Thanks, I removed the if condition, so it worked.

Ian Mildon
Tera Guru

You need to create an onChange catalog client script that sets the checkbox value to false whenever the request type field changes.

Hi, I have written the following script but it is not working. Can you please help?

 

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

if(newValue == 'true'){
g_form.setValue('menu', false);
g_form.setValue('function',false);

}}