Result of SUM

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mpol_ch
User
Posts: 877
Location: Switzerland

Result of SUM

Post by mpol_ch »

Hello
I trying to get the sum of the following code in Startup Script in Add.

Betraege = 90
Leistungen: 87

The results is deliverd for "Vortrag == 0" 9087 and not 177. Where should I check it?

thanks.
mpol_ch
$("#x_Vortrag").change(function() {
if (this.value == "0") {
var val1 = $("#x_Betraege").val();
var val2 = $("#x_Leistungen").val();
var sum = val1 + val2;
$("#x_Endbestand").val(sum) ;
// Set value to field #2
} else {
$("#x_Endbestand").val("800"); // Set value to field #2
}
});


mpol_ch
User
Posts: 877
Location: Switzerland

Post by mpol_ch »

I am sorry webmaster. I just founded out the mistake. "+" is missing.

This code is working perfectly. You can delete the tread.
mpol_ch

$("#x_Vortrag").change(function() {
if (this.value == "0") {
var val1 = $("#x_Betraege").val();
var val2 = $("#x_Leistungen").val();
var sum = +val1 + +val2;
$("#x_Endbestand").val(sum) ;
// Set value to field #2
} else {
$("#x_Endbestand").val("800"); // Set value to field #2
}
});


Post Reply