Trying to change a label dynamically by user selecting choices

CatchTheFletch
Tera Contributor

I have a catalog item that has two drop downs and a single text input field. I'm trying to create a client script that will update a label located below the three options listed above that updates as the user selects options. I'm a little stuck on how to do it. Would my best option be create an array that changes only after the last option (single line text) is input or should I have it update and change along the way as any of them change?

Currently I have the form setup so only the first drop down is shown until selected, then the second, then the single line text. I'm a little lost on how to script this though and the examples I've seen online aren't exactly what I'm looking for so I'm looking for any help here.

1 REPLY 1

Palak Gupta
Tera Guru
Tera Guru

Hi @CatchTheFletch ,

You can use below syntax in onChange Catalog Client script

if (newValue == "backend value of option 1")

{

var oldLabel = g_form.getLabelOf('comments');

g_form.setLabelOf('comments', oldLabel + ' (Customer visible)');

}

if (newValue == "backend value of option 2")

{

var oldLabel = g_form.getLabelOf('comments');

g_form.setLabelOf('comments', oldLabel + ' (Customer visible)');

}

if (newValue == "backend value of option 2")

{

var oldLabel = g_form.getLabelOf('comments');

g_form.setLabelOf('comments', oldLabel + ' (Customer visible)');

}

Please mark my answer correct and helpful if this resolves your issue.
Regards,
Palak