求助JAVAscript高手修改
<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><title>发...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>发票录入</title>
</head>
<body>
<SCRIPT language="javascript">
function $(id){return document.getElementById(id);}
window.onload=function(e){
$("zl").onkeyup=$("zl").onchange=$("dg").onkeyup=$("dg").onchange=$("sl").onkeyup=$("sl").onchange=function(e){
this.value=this.value.replace(/[^\d\.]/g,'');
$("je").value=Math.floor(($("zl").value-0)*($("dg").value-0) * 100) / 100;
$("jsr").value=Math.floor(($("je").value-0)/($("sl").value-0) * 100) / 100;
}
}
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#C4D8ED">
<tr>
<td width="100%" background="r_0.gif">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><b> 发票录入</b></td>
<td align="right"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table align="center" cellpadding="4" cellspacing="1" class="toptable grid" border="1">
<form name="form1" method="post">
<tr>
<td align="right" height="30">开票重量:</td>
<td class="category">
<input type="text" name="zl" style="width:80; height:19" id="zl" >
<font color="#808080">吨</font> </td>
</tr>
<tr>
<td align="right" height="30">单价:</td>
<td class="category">
<input type="text" name="dj" style="width:52; height:19" id="dg" >
<font color="#808080">元/吨</font> </td>
</tr><tr>
<td align="right" height="30">发票金额</td>
<td class="category">
<input type="text" name="je" style="width:93; height:19" id="je" >
<font color="#808080">元 </font></td>
</tr>
<tr>
<td align="right" height="30">税率</td>
<td class="category">
<SELECT name=sl id="sl" >
<OPTION selected value="1.06">6%</OPTION><option value="1.10">10%</option> <option value="1.16">16%</option>
</SELECT></td>
</tr>
<tr>
<td align="right" height="30">净收入</td>
<td class="category">
<input type="text" name="jsr" style="width:93; height:19" id="jsr" ></td>
</tr>
<tr>
<td height="30"> </td>
<td class="category"><input type="submit" value="确认" onClick="return check()" class="button">
<input type="hidden" name="hid1" value="ok">
<input type="reset" value=" 重新填写 " class="button"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
求助高手改改,比如重量或单价都不填时直接输入发票金额,我希望净收入随之所选税率自动重新计算,现在这代码如果是修改发票金额,净收入那不会计算。 展开
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>发票录入</title>
</head>
<body>
<SCRIPT language="javascript">
function $(id){return document.getElementById(id);}
window.onload=function(e){
$("zl").onkeyup=$("zl").onchange=$("dg").onkeyup=$("dg").onchange=$("sl").onkeyup=$("sl").onchange=function(e){
this.value=this.value.replace(/[^\d\.]/g,'');
$("je").value=Math.floor(($("zl").value-0)*($("dg").value-0) * 100) / 100;
$("jsr").value=Math.floor(($("je").value-0)/($("sl").value-0) * 100) / 100;
}
}
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#C4D8ED">
<tr>
<td width="100%" background="r_0.gif">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><b> 发票录入</b></td>
<td align="right"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table align="center" cellpadding="4" cellspacing="1" class="toptable grid" border="1">
<form name="form1" method="post">
<tr>
<td align="right" height="30">开票重量:</td>
<td class="category">
<input type="text" name="zl" style="width:80; height:19" id="zl" >
<font color="#808080">吨</font> </td>
</tr>
<tr>
<td align="right" height="30">单价:</td>
<td class="category">
<input type="text" name="dj" style="width:52; height:19" id="dg" >
<font color="#808080">元/吨</font> </td>
</tr><tr>
<td align="right" height="30">发票金额</td>
<td class="category">
<input type="text" name="je" style="width:93; height:19" id="je" >
<font color="#808080">元 </font></td>
</tr>
<tr>
<td align="right" height="30">税率</td>
<td class="category">
<SELECT name=sl id="sl" >
<OPTION selected value="1.06">6%</OPTION><option value="1.10">10%</option> <option value="1.16">16%</option>
</SELECT></td>
</tr>
<tr>
<td align="right" height="30">净收入</td>
<td class="category">
<input type="text" name="jsr" style="width:93; height:19" id="jsr" ></td>
</tr>
<tr>
<td height="30"> </td>
<td class="category"><input type="submit" value="确认" onClick="return check()" class="button">
<input type="hidden" name="hid1" value="ok">
<input type="reset" value=" 重新填写 " class="button"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
求助高手改改,比如重量或单价都不填时直接输入发票金额,我希望净收入随之所选税率自动重新计算,现在这代码如果是修改发票金额,净收入那不会计算。 展开
展开全部
function $(id) {
return document.getElementById(id);
}
var calc_total = function()
{
$("je").value = Math.floor(($("zl").value - 0) * ($("dg").value - 0) * 100) / 100;
};
var calc_net_income = function()
{
$("jsr").value = Math.floor(($("je").value - 0) / ($("sl").value - 0) * 100) / 100;
};
var wached_elements = {
zl:[calc_total, calc_net_income],
dg:[calc_total, calc_net_income],
je:[calc_net_income],
sl:[calc_net_income]
};
window.onload = function (e) {
$("je").onkeyup = $("je").onchange =$("zl").onkeyup = $("zl").onchange = $("dg").onkeyup = $("dg").onchange = $("sl").onkeyup = $("sl").onchange = function (e) {
wached_elements[this.id].map(function (f) {
f();
});
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询