json - Jquery .change function is not working through javascript -
.change call in jquery not working when change value through javascript.
for example:
$(document).ready(function () { $(function () { $("select#product").change(function () { if (document.all("fatcasearchdo.bankid").disabled.value = true) { fnfieldenableclass(document.all("fatcasearchdo.bankid")); } $.ajax({ type: 'get', url: 'viewhistorydataaction.do', data: { product: $(this).val() }, datatype: 'json', cache: false, success: function (j) { var options = ''; (var k = 0; k < j.length; k++) { options += '<option value="' + j[k] + '">' + j[k] + '</option>'; } $("select#bankid").html(options); } }); }); }); }); <html:select name="viewhistoryform" property="fatcasearchdo.bankid" styleclass="login-textbox" onchange="fnglobalchange();" onclick="checkradio('1')" onfocus = "checkradio('1')" styleid="bankid" style="width=250"> <html:select name="viewhistoryform" property="fatcasearchdo.product" styleclass="login-textbox" onchange="fnglobalchange();" onclick="checkradio('1')" onfocus = "checkradio('1')" styleid="product" style="width=250">
here when try change drop down of "product" calling action , respective bank id values populated. now, when try change value of "product" through javascript, instance
<input type="button" onclick="changeprod()"> function changeprod(){ document.all("fatcasearchdo.product").value='cc'; }
the change function not working.
when change value of input field through javascript, change event not fired.
you need fire change event manually
like
$("#fatcasearchdo.product").trigger('change')
ex:
function changeprod(){ $("#fatcasearchdo.product").val('cc').trigger('change'); }
Comments
Post a Comment