|
|
|
ต้องการรวมค่าในการกรอก textbox มารวมกัน พอจะมีวิธีไหนบ้างครับ |
|
|
|
|
|
|
|
จากโปรแกรมนับเงินของผม ลองประยุกต์ดูครับ
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">
<style>
a:link{
color: inherit;
}
/*close appearance*/
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
</style>
<script type="text/javascript">
function fncMath()
{
document.getElementById("jcash_1").innerHTML =parseInt(document.cash.cash_1.value)*1000;
document.getElementById("jcash_2").innerHTML =parseInt(document.cash.cash_2.value)*500;
document.getElementById("jcash_3").innerHTML =parseInt(document.cash.cash_3.value)*100;
document.getElementById("jcash_4").innerHTML =parseInt(document.cash.cash_4.value)*50;
document.getElementById("jcash_5").innerHTML =parseInt(document.cash.cash_5.value)*20;
document.getElementById("jcash_6").innerHTML =parseInt(document.cash.cash_6.value)*10;
document.getElementById("jcash_7").innerHTML =parseInt(document.cash.cash_7.value)*5;
document.getElementById("jcash_8").innerHTML =parseInt(document.cash.cash_8.value)*2;
document.getElementById("jcash_9").innerHTML =parseInt(document.cash.cash_9.value)*1;
document.getElementById("jcash_sum").innerHTML =
((parseInt(document.cash.cash_1.value)*1000)+(parseInt(document.cash.cash_6.value)*10)+
(parseInt(document.cash.cash_2.value)*500)+(parseInt(document.cash.cash_7.value)*5)+
(parseInt(document.cash.cash_3.value)*100)+(parseInt(document.cash.cash_8.value)*2)+
(parseInt(document.cash.cash_4.value)*50)+(parseInt(document.cash.cash_9.value)*1)+
(parseInt(document.cash.cash_5.value)*20));
}
</script>
</head>
<body style="background-color:#f4f4f4" onload="fncMath();" >
<form name="cash" id="cash" method="post" action="cash_open.php">
<table class="table" width="100%">
<thead>
<tr class=" btn-success">
<th colspan="7">นับเงิน</th>
</tr>
</thead>
<tbody style="font-size:smaller;">
<?PHP
$i_cash=1;
$cash_name = array("array0","ธนบัตร 1,000 บาท", "ธนบัตร 500 บาท", "ธนบัตร 100 บาท","ธนบัตร 50 บาท","ธนบัตร 20 บาท","เหรียญ 10 บาท","เหรียญ 5 บาท","เหรียญ 2 บาท","เหรียญ 1 บาท");
while($i_cash<=9) {
?>
<tr>
<th style="text-align:left; width:30%"><?=$cash_name[$i_cash]?></th>
<th style="text-align:left">จำนวน</th>
<th style="text-align:right"><input type="number" required autocomplete="off" onkeyup="fncMath();" name="cash_<?=$i_cash?>" id="cash_<?=$i_cash?>" style="text-align:right; width:50%" value="0" /></th>
<th style="text-align:left; color:#999999" >=</th>
<th style="text-align:right; color:#999999; width:20%"><span id="jcash_<?=$i_cash?>"></span></th>
<th style="text-align:right; color:#999999">THB</th>
</tr>
<? $i_cash++; } ?>
<tr class="well">
<th colspan="2" style="text-align:right; color:#666666"><a href="transfer_smart.php"><div class="btn btn-primary btn-sm glyphicon glyphicon-arrow-left" style="width:100%; text-align:left"> กลับ</div></a></th>
<th style="text-align:right; color:#666666">รวม</th>
<th style="text-align:left; color:#666666" >=</th>
<th style="text-align:right; color:#666666"><span id="jcash_sum"></span></th>
<th style="text-align:right; color:#666666">THB
</th>
</tr>
</tbody>
</table>
</body>
</html>
|
|
|
|
|
Date :
2016-05-27 16:59:40 |
By :
meannerss |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะลองปรับแก้ดูน่ะครับ ได้ผลยังไงจะมาลงไว้ ขอบคุณครับ
|
|
|
|
|
Date :
2016-05-27 22:00:58 |
By :
kikeeza01 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|