function chksum(chk,count){
var a = document.getElementById('data['+count+'][Quantity]').value
var b = document.getElementById('data['+count+'][Price]').value
var c = document.getElementById('data['+count+'][Price2]').value
var d = document.getElementById('data['+count+'][PricePerPiece]').value
var e = document.getElementById('data['+count+'][Dis_baht]').value
var f = document.getElementById('data['+count+'][Dis_Percent]').value
var g = document.getElementById('data['+count+'][Amount]').value
var h = document.getElementById('hidquantity').value
var i = document.getElementById('sumquantity').value
if(chk=="D"){
if(c=="0.00"){
document.getElementById('data['+count+'][Dis_baht]').value=-((d*1)-(b*1));
document.getElementById('data['+count+'][Dis_baht]').style.backgroundColor = "#A4E4DD";
document.getElementById('data['+count+'][Dis_baht]').readOnly = true;
}else{
document.getElementById('data['+count+'][Dis_baht]').value=(d*1)-(c*1);
document.getElementById('data['+count+'][Dis_baht]').style.backgroundColor = "#A4E4DD";
document.getElementById('data['+count+'][Dis_baht]').readOnly = true;
}
}
if(chk=="E"){
var numf = document.getElementById('data['+count+'][Dis_Percent]').value=100-((d/b)*100);
document.getElementById('data['+count+'][Dis_Percent]').value = parseFloat(numf).toFixed(0)+'%';
document.getElementById('data['+count+'][Dis_Percent]').style.backgroundColor = "#A4E4DD";
document.getElementById('data['+count+'][Dis_Percent]').readOnly = true;
}
if(chk=="F"){
document.getElementById('data['+count+'][Amount]').value=a*1*d;
document.getElementById('data['+count+'][Amount]').style.backgroundColor = "#A4E4DD";
document.getElementById('data['+count+'][Amount]').readOnly = true;
}
if(chk=="G"){
document.getElementById('hidquantity').value=a;
document.getElementById('sumquantity').value=(i*1)+(a*1);
}
}