When changing the value of a Ninja Forms field with jQuery, it is required that you also trigger a change event on the field’s input.
var fieldID = 197; | |
var newValue = 'compactpro'; | |
jQuery( '#nf-field-' + fieldID ).val( newValue ).trigger( 'change' ); |
The reason for this is that the fields/form is backed by a Backbone model which needs to be updated when a field is updated. While jQuery .val() updates the field’s input in the DOM, triggering the change event alerts Backbone that the value has changed.