RemoveOption onLoad Client Script

brown9394
Tera Expert

Hello Experts,

I have a requirement to remove State Options from State field when it gets to certain state and add new options. I'm an on load client script, but I can't remove any options nor can I add any options. Please Help!

function onLoad() {

if(state == '40'){

  g_form.removeOption('state', '10');

  g_form.removeOption('state', '20');

  g_form.removeOption('state', '30');

  g_form.addOption('state', '50', 'Execution');

  g_form.addOption('state', '60', 'Release');

}

}

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

Here you go.   But what about when some one changes the state?



function onLoad() {


if(g_form.getValue('state') == '40'){


  g_form.removeOption('state', '10');


  g_form.removeOption('state', '20');


  g_form.removeOption('state', '30');



  g_form.addOption('state', '50', 'Execution');


  g_form.addOption('state', '60', 'Release');


}


}


View solution in original post

5 REPLIES 5

Abhinay Erra
Giga Sage

Got you. Glad you got this fixed.