samuel toh samuel toh - 1 year ago 100
HTML Question

How to use 'on change' event on an input type hidden?

Demo and full code is like this :

http://jsfiddle.net/9R4cV/685/

I using like this :

$('#customer').on('change', function() {
$('#customer_copy').val($(this).val());
});


But it's not working

Any solution to solve my problem?

Answer Source
  1. You need to trigger .change() (or .trigger('change')) on input value changes, otherwise programatically changes are not triggering events.
  2. The id of your input is #customer not #customer_name.

$( "#tags" ).autocomplete({
    source: aTags,
    select: function(event, ui) {
        $("#customer").val(ui.item.label).change();
    }
});

$('#customer').on('change', function() {
    $('#customer_copy').val($(this).val());
});

Working example.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download