Populate value of a dropdown based on another dropdown value change
Posted: 2019-08-27 17:29
Hi Gurus,
When Invoice No below is selected, I want to populate value of Tenant.
Am using the below code
The Tenant dropdown is not populating the name.
When I inspect the element, the value is set as below
Please assist.
When Invoice No below is selected, I want to populate value of Tenant.
Am using the below code
Code: Select all
$j(document).on('change','#invoice_no-container', function(){
var invoiceid = $j('#invoice_no').val();
// console.log(invoiceid);
if ( invoiceid == '{empty_value}' ) {
$j('#tenant').val('');
}else{
$j.ajax({
url: 'ajax_payment.php',
data: { invoiceid:invoiceid },
success: function(resp){
var response = JSON.parse(resp)
console.log(response.tenantid);
$j('#tenant').val(response.tenantid).trigger('change');
}
});
}
});
When I inspect the element, the value is set as below
Code: Select all
<input type="hidden" name="tenant" id="tenant" value="27">