|
|
|
สอบถาม การบวก texbox ครับ ตอนนี้ติดตรง ราคารวม ไม่บวกค่า + ค่าสี และ ส่วนลดพิเศษ ครับ |
|
|
|
|
|
|
|
textbox ค่าสี กำหนดให้เป็น 0 ก่อน แต่ 0 ค่านี้ สามารถแก้เป็น 100 ได้ แต่ค่า ไม่ไปบวก กับ ราคารวม ครับ ราคารวม=2720 ที่ถูกต้องเป็น = 2820 ครับ รบกวนดูให้ที ครับ
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<title>test</title>
</head>
<body>
<table width="1030" height="385" border="0" align="center" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td width="63" height="383" colspan="6" align="center" valign="top"><table width="983" border="0" align="center" cellspacing="0">
<tr>
<td width="981" height="26" align="right" class="a3"> </td>
</tr>
</table>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.js"></script>
<script type="text/javascript">
function calcfunc(i) {
var val1 = parseFloat(document.getElementById("id1" + i).value);
var val2 = parseFloat(document.getElementById("id2" + i).value);
var Discount = parseFloat(document.getElementById("Discount" + i).value);
var result = ((val1*val2)-((val1*val2)*Discount/100)) ;
if (isFinite(result)) {
document.getElementById("id3" + i).value = result;
}
}
// Unidentifier from Thaicreate.com
$.fn.addCommas = function () {
return this.val().toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
};
$(document).ready(function(){
var tbody = $("#summaryTable tbody tr");
var Gtotal = $("input:text#grandTotal");
var Gtotal2 = $("input:text#grandTotal2");
var order_pledge = parseFloat(document.getElementById("order_pledge").value);
var color_order = parseFloat(document.getElementById("color_order").value);
var discount_order = parseFloat(document.getElementById("discount_order").value);
$("input:text",tbody).keyup(function(){
var total=0;
$("td:last-child > input:text",tbody).each(function(){
if($(this).val() != '')
total = parseFloat(total) + parseFloat($(this).val());
});
Gtotal.val(parseFloat(total)-(parseFloat(order_pledge))+(parseFloat(total)-(parseFloat(order_pledge)))*0.07);
Gtotal2.val( (parseFloat(total)-(order_pledge) + (color_order)+ (discount_order)));
});
});
</script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(function(){
$("#process").click(function(){
var stock_order_member_rest = $("input[name*=stock_order_member_rest]")
var stock_order_member_send = $("input[name*=stock_order_member_send]")
var aar = [];
var aat = [];
var ssi = $("input[name*=stock_order_member_rest]").size()
stock_order_member_rest.each(function(value, key){
aar.push($(key).val())
})
stock_order_member_send.each(function(value, key){
aat.push($(key).val())
})
for(i=0;i<ssi;i++)
{
$("#stock_order_member_rest"+i).val(aar[i] - aat[i])
}
})
})
</script>
<script type="text/javascript">
function chk_value(i) {
var stock_order_member_rest = parseFloat(document.getElementById("stock_order_member_rest" + i).value);
var val22 = parseFloat(document.getElementById("id1" + i).value);
if(stock_order_member_rest < val22){
alert(' กรอกจำนวนเกินที่เหลือ!! ');
$('#id1'+i).val("");
}
}
</script>
<form action='invoice_bin_in.php' method='post' name = "form" >
<table width="200" border="0" align="center" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td>
<table id="summaryTable" width="900" border="1" align="center" cellspacing="0" bordercolor="#CCCCCC">
<tr class="gf">
<td width="30" align="center" valign="middle" bgcolor="#CCCCCC"> </td>
<td width="173" align="center" valign="middle" class="sf" bgcolor="#CCCCCC" style="font-size: 18px">รุ่นสินค้า</td>
<td width="176" align="center" valign="middle" class="sf" bgcolor="#CCCCCC" style="font-size: 18px; font-family: AngsanaUPC;">ขนาด</td>
<td width="88" align="center" valign="middle" class="sf" bgcolor="#CCCCCC" style="font-size: 18px; font-family: AngsanaUPC;">จำนวน</td>
<td width="78" align="center" valign="middle" class="sf" bgcolor="#CCCCCC" style="font-size: 18px">จำนวนเหลือ</td>
<td width="88" align="center" valign="middle" class="sf" bgcolor="#CCCCCC" style="font-size: 18px; font-family: AngsanaUPC;">จำนวนส่ง</td>
<td width="88" align="center" valign="middle" class="sf" bgcolor="#CCCCCC" style="font-size: 18px; font-family: AngsanaUPC;">ราคา</td>
<td width="99" align="center" valign="middle" class="sf" bgcolor="#CCCCCC" style="font-size: 18px; font-family: AngsanaUPC;">ส่วนลด%</td>
<td width="98" align="center" valign="middle" class="sf" bgcolor="#CCCCCC" style="font-size: 18px">รวม</td>
</tr>
<tbody>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;">
1 </td>
<td align="left" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC; text-align: left;">AMU
<input name="stock_order_ID[]" type="hidden" id="stock_order_ID" value="17631" size="30" />
<input name="stock_order_generation[]" type="hidden" id="stock_order_generation" value="VD" size="30" />
<input name="stock_idcode_pb[]" type="hidden" id="stock_idcode_pb" value="KF-1-2014-7032" size="30" /></td>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;"><strong>
<input name="stock_order_size[]" type="hidden" id="stock_order_size" value="29.5 X 29.5 cm" size="30" />
</strong>
29.5 X 29.5 cm </td>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;">
2 <input name="stock_order_member[]" type="hidden" id="stock_order_member" value="2" size="5" />
</td>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;">
2 <input type="hidden" name="stock_order_member_rest[]" id="stock_order_member_rest0" onKeyUp="calcfunc(0)" value="2" size="3" />
</td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<input type="text" name="stock_order_member_send[]" id="id10" onKeyUp="calcfunc(0)" onchange="chk_value(0)" value="2" size="10" />
</td>
<td align="center" valign="middle" bgcolor="#FFFFFF"><input name="stock_price[]" type="text" id="id20" onKeyUp="calcfunc(0)" value="600" size="10" /></td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<input name="Discount[]" type="text" id="Discount0" onKeyUp="calcfunc(0)" value="0"
size="10" /></td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<input type="text" id="id30" onkeyup="calcfunc(0)" name="stock_price_sum[]" size="15" />
</td>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;">
2 </td>
<td align="left" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC; text-align: left;">OAR
<input name="stock_order_ID[]" type="hidden" id="stock_order_ID" value="17632" size="30" />
<input name="stock_order_generation[]" type="hidden" id="stock_order_generation" value="VD" size="30" />
<input name="stock_idcode_pb[]" type="hidden" id="stock_idcode_pb" value="KF-1-2014-7032" size="30" /></td>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;"><strong>
<input name="stock_order_size[]" type="hidden" id="stock_order_size" value="44.5 X 59.5 cm" size="30" />
</strong>
44.5 X 59.5 cm </td>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;">
2 <input name="stock_order_member[]" type="hidden" id="stock_order_member" value="2" size="5" />
</td>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;">
2 <input type="hidden" name="stock_order_member_rest[]" id="stock_order_member_rest1" onKeyUp="calcfunc(1)" value="2" size="3" />
</td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<input type="text" name="stock_order_member_send[]" id="id11" onKeyUp="calcfunc(1)" onchange="chk_value(1)" value="2" size="10" />
</td>
<td align="center" valign="middle" bgcolor="#FFFFFF"><input name="stock_price[]" type="text" id="id21" onKeyUp="calcfunc(1)" value="1760" size="10" /></td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<input name="Discount[]" type="text" id="Discount1" onKeyUp="calcfunc(1)" value="0"
size="10" /></td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<input type="text" id="id31" onkeyup="calcfunc(1)" name="stock_price_sum[]" size="15" />
</td>
</tr>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;"> </td>
<td align="left" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC; text-align: left;"><span style="font-size: 18px; font-family: AngsanaUPC;"><span class="af"><span class="sf" style="font-size: 18px; text-align: left;">
หักมัดจำ <input name='order_pledge' type='hidden' id='order_pledge' value='2000' /> </span></span></span></td>
<td colspan="7" align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC; text-align: left;"><span class="af"><span class="sf" style="font-size: 18px; text-align: left;">
2000 </span></span></td>
</tr>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;"> </td>
<td align="left" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC; text-align: left;"><span class="af"><span class="sf" style="font-size: 18px; text-align: left;">ค่าสี </span></span></td>
<td colspan="7" align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC; text-align: left;"><span class="af"><span class="sf" style="font-size: 18px; text-align: left;"><span class="sf" style="font-size: 18px; text-align: left;">
<input name="color_order" type="text" id="color_order" value="0" size ="10"/>
</span></span></span></td>
</tr>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC;"> </td>
<td align="left" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC; text-align: left;"><span class="af"><span class="sf" style="font-size: 18px; text-align: left;">ส่วนลดพิเศษ </span></span></td>
<td colspan="7" align="center" valign="middle" bgcolor="#FFFFFF" style="font-size: 18px; font-family: AngsanaUPC; text-align: left;"><span class="af"><span class="sf" style="font-size: 18px; text-align: left;">
<input name="discount_order" type="text" id="discount_order" value="0" size ="10"/>
</span></span></td>
</tr>
</tbody>
</table>
<table width="900" border="0" align="center" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td width="114" align="left" valign="middle" bgcolor="#FFFFFF" class="af"> </td>
<td width="565" align="left" valign="middle" bgcolor="#FFFFFF" class="af"></td>
<td width="90" height="45" align="right" valign="middle" bgcolor="#FFFFFF" class="sf" style="font-size: 18px">ราคารวม
<br />
ราคารวม vat 7</td>
<td width="5" align="center" valign="middle" bgcolor="#FFFFFF"> </td>
<td width="116" align="center" valign="middle" bgcolor="#FFFFFF"><input name="sum_not_vat" type="text" id="grandTotal2" size ="15"/>
<br />
<input name="sum_vat" type="text" id="grandTotal" size ="15"/></td>
</tr>
</table></td>
</tr>
</table>
<br />
<input type='submit' name='Submit' id='process' value='บันทึก'/>
<br />
</form></td>
</tr>
<tr>
<td height="2" colspan="6" valign="middle"></td>
</tr>
</table>
<span style="font-size: 18px; -align: left; font-family: AngsanaUPC;">
</span>
</body>
</html>
Tag : PHP, JavaScript, Action Script, Ajax, jQuery
|
|
|
|
|
|
Date :
2014-03-04 13:51:02 |
By :
rock_rock |
View :
822 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
บรรทัดที่ 042. ค่าของ total ควรจะบวกไปเรื่อยๆนะครับ
total += xxxxxxxxxxxxxxxxxxxxxx
|
|
|
|
|
Date :
2014-03-04 15:46:09 |
By :
{Cyberman} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แนะนำหน่อย ครับ อยากให้ เวลา เปลี่ยน ค่า อยากให้ผลรวมเปลี่ยนด้วย เหมือนกับ ช่อง รวม ครับ
|
|
|
|
|
Date :
2014-03-05 14:12:04 |
By :
rock_rock |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองดูครับ ประยุกต์เอานะ โค้ดมันยาวเกินไปอ่านไม่ไหว 5 5 5
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function fncSubmit(){
var num1 = document.getElementById('text1').value;
var num2 = document.getElementById('text3').value;
var num3 = document.getElementById('text2').value;
if (num1=="") { num1=0; }
if (num2=="") { num2=0; }
if (num3=="") { num3=0; }
var result_num = parseFloat(num1)+parseFloat(num2)+parseFloat(num3);
document.getElementById('result').value=result_num;
return;
}
</script>
<input name="text1" type="text" id="text1" size="3" onkeyup="fncSubmit();" />
+
<input name="text2" type="text" id="text2" size="3" onkeyup="fncSubmit();" />
+
<input name="text3" type="text" id="text3" size="3" onkeyup="fncSubmit();" />
=
<input name="result" type="text" id="result" size="3" readonly />
|
|
|
|
|
Date :
2014-03-05 15:26:39 |
By :
meannerss |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|