How to retrieve parent ID on load
Posted: 2020-07-10 02:23
Hi there,
Appreciate if someone can teach me how to retrieve the ID of parent table which automatically generated when we click add item at child table.
Example, when I click the add item here... I will get this modal window with the parent ID already assigned as 10778 What I want to do is actually retrieve the value of one of the field from the parent table based on the ID.
I have the following js to retrieve it on change but what I want is to retrieve it on load.
Appreciate your help and support.
Thanks.
Zala
Appreciate if someone can teach me how to retrieve the ID of parent table which automatically generated when we click add item at child table.
Example, when I click the add item here... I will get this modal window with the parent ID already assigned as 10778 What I want to do is actually retrieve the value of one of the field from the parent table based on the ID.
I have the following js to retrieve it on change but what I want is to retrieve it on load.
Code: Select all
$j('#Service_ID-container').on('change', function () {
var pid = $j('#Service_ID-container').select2('val');
if (pid == '{empty_value}') {
$j('#Amount').val('');
} else {
$j.ajax({
url: 'hooks/ajax-service_item_balance.php',
data: {
pid: pid
},
success: function (data) {
$j('#Amount').val(data);
}
});
}
});
Thanks.
Zala