2

I want to know how to change the value of those awesome civicrm comboboxes from the code (i have google address search, I need to change the country), see the screenshot. jQuery("#country-1").val(val); document.getElementById('country-1').value = val; don't work enter image description here

1 Answer 1

2

The widget is select2 3.5. But you don't need to interact with it directly. Find a selector for the underlying <select> element in the dom, set it's value, and then fire the change event. E.g.

CRM.$(function($) {
  $("#country-1").val(val).change()
});

Note that you should use CiviCRM's copy of jQuery and not the WP copy. So the above code uses CRM.$ instead of jQuery. Using the wrong copy of jQuery would make things weird as change events would appear to have no effect, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.