- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 12:40 AM
Hello all, I need some assistance to the following requirement.
I have a record producer on SP, where depending on the category selection, only related subcategories are visible.
For instance, for the category "hardware", only the following subcategories are visible.
However, if I change to another category (for example "software"), all the options are not visible (only the option "--None--" is visible). Then, if I return back to the category "hardware", all the previous options (shown on the first image) are not visible any more as shown below.
I am using a Catalog Client Script (onChange), that gets the value of the field category, and based on that value removes all the unrelated options on the subcategory field. My script looks like this:
Any assistance would be really helpful.
Thank you all in advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 12:52 AM
Hi,
Try using format as below
g_form.removeOption('variable_name','value','label');
So,
g_form.removeOption('subcategory','11','CPU'); //suppose 11 is value while CPU is label.
In addition, you need to use g_form.addOption() as well. So, for your case suppose
if(cat==8)
{
g_form.removeOption('subcategory','11','CPU');
..
g_form.addOption('subcategory','7'); //choice you want to show
...
}
So, for every .removeOption() you need to use .addOption() to add & make it work independently.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 01:43 AM
No problem. All the best to your learning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2024 07:49 AM
Good info Jaspal.
I found that by adding the value and label ONLY to the removeOption worked great, however, I'd have a blank space below my choice list. Weird.
So I also added the value and label to the addOption function and it worked great.
This is in Vancouver