The CreatorCon Call for Content is officially open! Get started here.

Client script for Record Producer

servicetrout
Tera Expert

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'); }

}

1 ACCEPTED SOLUTION

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');




}


 


}



find_real_file.png



find_real_file.png


Regards
Harish

View solution in original post

19 REPLIES 19

Yes, it is available and the alert will display a popup widow with the text in it similar to this as you make changes to the selected field:


find_real_file.png


Thank you, Jim.   I will definitely remember this - very helpful !


Worked like a charm once I added the variable name to the client script field.


haseena ayesha
Kilo Guru
 

Hi


Glenn,


Check   this ones, and are you giving currect fieldname..?



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


        var choice = g_form.getValue('u_choices');


  if (choice == 'value2') {


  g_form.setValue('name','Yahoo');


  }



Thanks & Regards


Haseena              


                                                                              PS: Hit like, Helpful or Correct depending on the impact of the response


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');




}


 


}



find_real_file.png



find_real_file.png


Regards
Harish

Thanks.   My bad.   Missed entering the variable name after I started making changes.   Yes, works like a charm.