Writing a onChange Client script when the value form SelectBox Changes the dependent value get clear

Ishwar Havagi
Tera Contributor

Hi All,

 

I'm currently trying to fix a small onChange client Script whose dependent values should get changed when the SelectBox Option gets changed.

In this case I have created one SelectBox with two choices on selection of one choice will give you different List Collector Value and on another selection different List Collector gets Visible and Selection of those List Collector those different fields gets visible and now if we try to change the SelectBox option then the below values are not getting removed instead the old value fields are getting settled there itself.

 

Eg: SelectBox Name: System Landscape with two choices (SAP MBC and SAP SBC)

On selection of SBC then List Collector fields (Main System) gets visible and then after selecting the values from list collector the Sub System SelectBox gets visible.

 

Script: Currently tying when the SBC is getting select then the options from the field of MBC should get  clear and vice versa.

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
    if(newValue == 'SAP SBC'){
        g_form.clearValue('main_system_os');
    }
    if(newValue == 'SAP MBC'){
        g_form.clearValue('main_system_kg');
    }
   //Type appropriate comment here, and begin script below
}
 

 

Any solutions for this or rather another way to accomplish this requirement.

Thanks In Advance!

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

This is a good approach.  Ensure 'SAP SBC' / MBC are the actual values.  Add an alert on newValue if you are unsure.