- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 04:18 PM
Have variable in my record producer with Field name, u_testchoice, which is a select box with values ("none", "value1","value2",and "value3").
When the user sets that u_testchoice field value to "value2", I want my client script to set the record producer field named u_teststring to "Yahoo".
Here is my code, which seems to do nothing.
function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == ' ') {
return;
}
//Type appropriate comment here, and begin script below
if (producer.u_testchoice == 'value2'){
g_form.setValue('u_teststring','Yahoo'); }
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 09:20 PM
It does work for me
//tested
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert('load');
g_form.clearValue('test_string');
var choice = g_form.getValue('u_testchoice');
alert(choice);
if (choice == 'value_2') // value_2 is the value of the choice
{
alert('inside');
g_form.setValue('test_string','Yahoo');
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 08:13 PM
Can you paste screen shot of catalog client script here so we can check?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 08:57 PM
Literally what you see above is what appears, exluding the initial comment and variations at the bottom.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 09:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 09:37 PM
Arrggg! I completely missed what you were aluding to the first time, but THAT was the second problem - I had nothing in there !
I had changed it so many times, then got lost in the code.
The coding correction was the first issue.
Thank you for sharing your insight !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 08:19 PM
You might want to add an alert statement to see what value is that you are getting from the variable:
function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == '') {
return;
}
var choice = g_form.getValue('u_testchoice');
alert(choice); //*** this will show you what you are getting ***************
if (choice == 'value2') {
g_form.setValue('u_teststring','Yahoo');
}
}
You will want to make sure you are using the "value" of the Choice item and not the "label" when comparing on line 7.