|
 |
|
ช่วยด้วยครับ ผมจะแก้ไขโค๊ดนี้อย่างไรดีครับ โจทย์คือ ให้ นักศึกษา/อาจารย์ => 1/บุคคลทั่วไป => 2/โชลเชี่ยล =>3 |
|
 |
|
|
 |
 |
|
โจทย์คือ ให้
นักศึกษา/อาจารย์ => 1
บุคคลทั่วไป => 2
โชลเชี่ยล =>3
ข้อมูลที่ส่งมาเป็นแบบนี้ครับ => {"tType":"CUSTOMER","aoCustomer":[{"FTCstType":1,"FDXihDocDate":12/08/2018,"FTXihDocTime":15:00:00}]}
ถ้า FTCstType มันเท่ากับ 1 ก็ให้ไปบวกกับในตาราง นักศึกษา/อาจารย์ (+1)
ถ้า FTCstType มันเท่ากับ 2 ก็ให้ไปบวกกับในตาราง บุคคลทั่วไป (+1)
ถ้า FTCstType มันเท่ากับ 2 ก็ให้ไปบวกกับในตาราง โชลเชี่ยล (+1)
ทำแบบนี้ไปเรื่อยๆ ครับ
ผมจะแก้โค๊ดนี้ได้อย่างไรบ้างครับแก้ไม่ถูกครับผม
Code (PHP)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
// FTRcvCode ="1" => "นักศึกษา"
// FTRcvCode ="2" => "บุคคลทั่วไป"
// FTRcvCode ="3" => "โซเชียล"
function SigmalRUpdateData(){
var myjson = '{"tType":"CUSTOMER","aoCustomer":[{"FTCstType":1,"FDXihDocDate":12/08/2018,"FTXihDocTime":15:00:00}]}';
// console.log(myjson)
var myArr = $.parseJSON(myjson);
for(var i = 0; i<myArr['aoCustomer'].length;i++){
tGpgCode = myArr['aoCustomer'][i].FTCstType;
tPgpName = myArr['aoCustomer'][i].FDXihDocDate;
nPaymentAmt = myArr['aoCustomer'][i].FTXihDocTime;
nCountPgpRow = $('table tr td:contains("'+tGpgCode+'")').length
if(nCountPgpRow == 0){
$('#otbPaymantGroup').append($('<tr>')
.append($('<td>')
.text(tGpgCode)
.attr('id','otdStkGpg'+tGpgCode)
)
.append($('<td>')
.text(nPaymentAmt)
.attr('id','otdPayMentAmt'+tGpgCode)
)
);
}else{
nLastAmt = parseFloat($('#otdPayMentAmt'+tGpgCode).text());
nIncommingAmt = parseFloat(nPaymentAmt);
nNewAmt = nLastAmt + nIncommingAmt;
$('#otdPayMentAmt'+tGpgCode).text(nNewAmt);
}
}
}
</script>
<button onclick="SigmalRUpdateData()">SignalR</button>
<table class="table table-bordered" id="otbPaymantGroup">
<thead>
<tr>
<th>นักศึกษา/อาจารย์</th>
<th>บุคคลทั่วไป</th>
<th>โชลเชี่ยล</th>
</tr>
</thead>
<tbody>
<tr>
<td id="otdStkGpg1">2</td>
<td id="otdStkGpg1">0</td>
<td id="otdStkGpg1">0</td>
</tr>
</tbody>
</table>
Tag : PHP, HTML, CSS

|
|
 |
 |
 |
 |
Date :
2018-09-03 18:59:05 |
By :
witsarut_bell |
View :
557 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ให้ส่วนของ tbody มีไว้ 1 row ก่อนครับ
แล้วใช้ + ค่าจากค่าเดิมเอาครับ
|
 |
 |
 |
 |
Date :
2018-09-04 09:25:15 |
By :
Jatmentz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|