You are viewing limited content. For full access, please sign in.

Question

Question

assigning value to dropdown doesn't trigger database lookup

asked on February 27, 2015

Hi.

I have a form with a dropdown list of users and a radio button that controls whether to fill in the dropdown field automatically or to have a user fill it in.

If the user fills it in, the database lookup trigger that is set to fire on the dropdown list field works fine. However, when the dropdown is filled in automatically with Javascript, the lookup isn't triggered.

How can I get a database lookup to be triggered when the dropdown field value is selected with Javascript?

Here's the script I've got:

 function setDropdownValue() {

        // this is the radio button that determines whether the user has to choose from the

       // dropdown or whether the value should be filled in automatically

       var reqFor = $('input[name="Field77"]:checked').val();

       // This is the value that will be used to automatically fill the dropdown field

       var usrdispname = $('#q164 input').val();

    

        if (reqFor == 'me') {

          // set the field value automatically

          $('select[id="Field147"]').val(usrdispname);

          // $('#Field147 input').trigger('change');

      } else {

               $("#Field147").val("");

      }              

}

2 0

Replies

replied on February 27, 2015

I got it! I just had to add ".change()" to the end of the select:

$('select[id="Field147"]').val(usrdispname).change();

3 0
You are not allowed to follow up in this post.

Sign in to reply to this post.