日期:2014-05-16 浏览次数:20392 次
<!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>无标题文档</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//代码...
})
function divchargeMoney(money){
money.value = money.value.replace(/[^\d.]/g,"");
money.value = money.value.replace(/^\./g,"");
money.value = money.value.replace(/\.{2,}/g,".");
money.value = money.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
//var _thisval = $("#RechargeForm_money").val();
//alert($(money).val()!='');
if(!isNaN($(money).val()) && $(money).val()!=''){
$(".danhang_total_sum").html((parseFloat($(money).val())*parseFloat($("#num").text())).toFixed(2));
}else{
$(".danhang_total_sum").html("");
}
}
</script>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th>数量</th>
<th>单价</th>
<th>总价</th>
</tr>
<tr>
<td><span id="num">3</span></td>
<td><input type="text" onkeyup="divchargeMoney(this)"></td>
<td><span class="danhang_total_sum"></span></td>
</tr>
<tr>
<td colspan="2"><span style="color:red">总计:</span></td>
<td><span style="color:red">¥</span><span class="total_sum"></span></td>
</tr>
</table>
<br />
<br />
<br />
<hr>
<br />
<br />
<br />
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th>数量</th>
<th>单价</th>
<th>总价</th>
</tr>
<tr>
<td><span id="num">3</span></td>
<td><input type="text" ></td>
<td><span class="danhang_sum"></span></td>
</tr>
<tr>
<td><span id="num">8</span></td>
<td><input type="text" >