Auto update column in master table before save record

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
shahparzsoft
User
Posts: 361

Auto update column in master table before save record

Post by shahparzsoft »

I am using the following script in at :
Client Scripts->Table Specific->List Page-> Startup Script

function calculateSum() {
var sum = 0;
//iterate through each textboxes and add the values
$("[data-field=x_orderdetails_sitotal]").each(function () {// line total field in details field
//add only if the value is number
if (!isNaN(this.value) && this.value.length != 0) {
sum += parseFloat(this.value);
}
});
$("#x_orders_sigtotal").val(sum.toFixed(2));// id of field in master table
}
<?php if(CurrentPageID() == "add"){?>
$("#tbl_detail_tablegrid").on("change", "[data-field=x_field_x]", function () {//activate fxn on change on specific field in detail table
calculateSum();
});
<?php }?>

But nothing is changing when value changed in the column name x_orderdetails_sitotal]

Any solution or advise ? (v2021)


mobhar
User
Posts: 11745

Post by mobhar »

Please note that since v2021, all the Javascript either that written from Client Script or Startup Script will be placed/generated into .js file. Therefore, we cannot mix the code with PHP code anymore. You need to find out the related PHP code in Javascript.

For your case, you may use ew.PAGE_ID Javascript variable to identify the current page id in client side.


Post Reply