How do I clear the select box values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2008 09:58 AM
I would like to clear a select box of all values without knowing their values.
We have two select boxes called service provider and model.For example if i select "Verizon" within the service provider then the available models appears in the model select box type(for example,8830,8820,Other...).
We have an another Yes/No type field(prior).
If i select "Yes" within this field,then the two select boxes(service provider,model) becomes -- None--
but left the other values there.I'm looking for a way to clear a select box of all values.
I tried setValue,removeOprtion and i tried the following script.
var pri = g_form.getValue('prior');
if(pri == 'Yes')
{
g_form.setValue('model',' ');
var option = ' ' ;
g_form.setValue('Other',option);
}
Thanks...
- Labels:
-
Orchestration (ITOM)
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2008 05:29 AM
Hi there,
I have just tried this and
g_form.setValue('field_name', '') ;
seems to work and so I cannot see why what you have done has not.
Regards, Ruth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2008 08:01 AM
If you want to remove the entries from the select entriely:
g_form.getControl('category').options.length = 0;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2008 08:16 AM
Nice one. Just added to Client Scripts wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2008 11:43 AM
The following script is working,
g_form.removeOption('model',8820);
g_form.removeOption('model',8310);
g_form.removeOption('model',8800);
g_form.removeOption('model',8830);
Here model - Name of the select box
8820,8310... - Values within the select box.