JS 文本框sum_money如果计算总价(合计)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS 文本框sum_money如果计算总价(合计)相关的知识,希望对你有一定的参考价值。
<Script Language=JavaScript Type=Text/JavaScript>
function insertrows()
for(var i=0;i<document.ck.elements.length-6;i++)
if(document.ck.elements[i].value=="")
break;
else if(document.ck.elements[i].value!=""&& i==document.ck.elements.length-7)
var theTable = document.getElementById("table1");
var rowNumber = parseFloat(theTable.rows.length);
theTable.insertRow(rowNumber);
for (var j=0;j<=theTable.rows[rowNumber-1].cells.length-1;j++)
var newValue="<input type='text' class='inputfield2' onFocus='focusChange(this.name)' onBlur='blurChange(this.name)' onkeydown='if(event.keyCode==13)event.keyCode=9' style='width:86px;z-index:-1' name='r"+rowNumber+"c"+j+"' id=''r"+rowNumber+"c"+j+"' >";
theTable.rows[rowNumber].insertCell(j);
theTable.rows[rowNumber].cells[j].innerHTML = newValue;
theTable.rows[rowNumber].cells[0].innerHTML="<div align='center'></div>";
theTable.rows[rowNumber].cells[0].className="borderon2";
theTable.rows[rowNumber].cells[7].innerHTML="<input type='text' class='inputfield2' onFocus='focusChange(this.name)' onBlur='blurChange(this.name)' onkeydown='if(event.keyCode==13)event.keyCode=9' style='width:72px;z-index:-1' name='r"+rowNumber+"c7' id='r"+rowNumber+"c7' readonly='true'>";
</Script>
function insertrows()
for(var i=0;i<document.ck.elements.length-6;i++)
if(document.ck.elements[i].value=="")
break;
else if(document.ck.elements[i].value!=""&& i==document.ck.elements.length-7)
var theTable = document.getElementById("table1");
var rowNumber = parseFloat(theTable.rows.length);
theTable.insertRow(rowNumber);
for (var j=0;j<=theTable.rows[rowNumber-1].cells.length-1;j++)
var newValue="<input type='text' class='inputfield2' onFocus='focusChange(this.name)' onBlur='blurChange(this.name)' onkeydown='if(event.keyCode==13)event.keyCode=9' style='width:86px;z-index:-1' name='r"+rowNumber+"c"+j+"' id=''r"+rowNumber+"c"+j+"' >";
theTable.rows[rowNumber].insertCell(j);
theTable.rows[rowNumber].cells[j].innerHTML = newValue;
theTable.rows[rowNumber].cells[0].innerHTML="<div align='center'></div>";
theTable.rows[rowNumber].cells[0].className="borderon2";
theTable.rows[rowNumber].cells[7].innerHTML="<input type='text' class='inputfield2' onFocus='focusChange(this.name)' onBlur='blurChange(this.name)' onkeydown='if(event.keyCode==13)event.keyCode=9' style='width:72px;z-index:-1' name='r"+rowNumber+"c7' id='r"+rowNumber+"c7' readonly='true'>";
</Script> 参考技术A JavaSc
JS 文本框加法运算保留2位小数
用以下代码计算小数运算,会出现多位小数,如何精准保存2位小数!本人小白,请大侠提供完整代码
<SCRIPT LANGUAGE="JavaScript">
window.onload = function()
var inputs = document.getElementsByTagName("input");
for(i=0;i<inputs.length;i++)
inputs[i].onblur = function()
var add1 = document.getElementById("add1").value;
var add2 = document.getElementById("add2").value;
var add3 = document.getElementById("add3").value;
document.getElementById("sum").value = add1*1 + add2*1+ add3*1;
</SCRIPT>
<input id="add1" type="text"/> +
<input id="add2" type="text"/> =
<input id="add3" type="text"/> =
<input id="sum" type="text"/>
以上是关于JS 文本框sum_money如果计算总价(合计)的主要内容,如果未能解决你的问题,请参考以下文章