How to use javascript in default value tab of lookup select box?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2019 02:13 AM
Hi everyone,
I try to figure out how I can use javascript in the default value tap of an variable (lookup select box) in a catalog item.
My select box variable is based on a prior lookup select box on the form. The second one shows based on a m2m table particular options depending on the choice in first lookup select box. How can I set a default values for the second lookup select box? Keeping in mind that the options are differing depending on the choices that were made in first place.
For now i started with this script on the default value tap, but apparently it didn't work.
javascript: if(current.variables.<variable name of first lookup select box>=='OptionX')
{
g_form.setValue('variable name of 2nd lookup selectbox',DefaultValue of Option X);
}
Or do I need a catalog client script for this one? If yes, how should it look like?
Thanks!!!
- Labels:
-
Request Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2019 02:33 AM
Hi Alexandra,
you can't use g_form in the Default Value, you have to create a catalog client script and put the following code:
if(current.variables.<variable name of first lookup select box>=='OptionX')
g_form.setValue('variable name of 2nd lookup selectbox',DefaultValue of Option X);
If I have answered your question, please mark my response as correct and/or helpful so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thank you
Cheers
Alberto

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2019 02:53 AM
Hi Alberto,
thanks for your answer. I tried to create a catalog client script. But the Catalog Client Script doesn't accept
current.variables.<variable name of first lookup select box>
because of "current", is there another way to get the value of the current variable?
Alexandra