when I select the none option in the field then another field also will be the same like None

Bunny45
Tera Contributor

I have taken two fields which are "City" and "Pin code". both the city and pin code fields already include "-- None --", and  want to set the pin code field to "-- None --" when "None" is selected in the city field, 

I  have written the client script for When the choice value is selected in the City field then adding the options Here Working properly (added options when i select the city choice))Here Working properly (added options when i select the city choice))Here i went back it means i select none, but it still showing pin code valueHere i went back it means i select none, but it still showing pin code valueon the Choices to the Pin code field.

 options are added to the "Pin code" field properly but,

when the 'none' option is selected it shouldn't clear the existing value.

it shows the existing value even though I select the "none" option in the "city" field.

 

Note :  on the Service Portal,


I tried the below code:

 

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

   if (newValue == 'Hyd') {
      g_form.clearOptions('u_pin_code');
      g_form.addOption('u_pin_code', '100001', '100001');
      g_form.addOption('u_pin_code', '100002', '100002');
      g_form.addOption('u_pin_code', '100003', '100003');
   } else if (newValue == 'Bangalore') {
      g_form.clearOptions('u_pin_code');
      g_form.addOption('u_pin_code', '200001', '200001');
      g_form.addOption('u_pin_code', '200002', '200002');
      g_form.addOption('u_pin_code', '200003', '200003');
   } else if (newValue == 'Chennai') {
      g_form.clearOptions('u_pin_code');
      g_form.addOption('u_pin_code', '300001', '300001');
      g_form.addOption('u_pin_code', '300002', '300002');
      g_form.addOption('u_pin_code', '300003', '300003');
   } else if (newValue == '-- None --') {
      g_form.setValue('u_pin_code', '-- None --');
   }
}



0 REPLIES 0