页面计算的问题JScript codeform idnewForm namenewFormtable width65% aligncenter class
页面计算的问题
- JScript code
<form id="newForm" name="newForm"><table width="65%" align="center" class="t1" border="1" cellspacing="0" cellpadding="0" id='newtable'><tr> <th nowrap="nowrap" colspan="8" width="65%" background="<c:url value="/images/head.gif"/>"><font color="blue" size="2">一炼铁部</font></th></tr><tr> <th nowrap="nowrap" width="8%" background="<c:url value="/images/head.gif"/>"><font size="2">1#入炉烧结矿</font></th> <td nowrap="nowrap" width="8%" align="center"><font size="2"><input type="text" id="ylt_rlsjk1" name="ylt_rlsjk1" value="${yjrbph.ylt_rlsjk1}" onafterpaste="value=value.replace(/[^\d\.]/g,'')" style="width:80px;text-align:right" onfocus="javascript:this.select();" onblur="on_blur(this.value,this.id)" onkeydown="kuanghao(this.value,this.id)" onkeyup="on_keypress('ylt_rlets1');"></font> </td> </tr><tr> <th nowrap="nowrap" width="8%" background="<c:url value="/images/head.gif"/>"><font size="2">1#入炉二铁烧</font></th> <td nowrap="nowrap" width="8%" align="center"><font size="2"><input type="text" id="ylt_rlets1" name="ylt_rlets1" value="${yjrbph.ylt_rlets1}" onafterpaste="value=value.replace(/[^\d\.]/g,'')" style="width:80px;text-align:right" onfocus="javascript:this.select();" onblur="on_blur(this.value,this.id)" onkeydown="kuanghao(this.value,this.id)" onkeyup="on_keypress('ylt_rlzcq1');"></font> </td> </tr><tr> <th nowrap="nowrap" width="8%" background="<c:url value="/images/head.gif"/>"><font size="2">1#入炉自产球</font></th> <td nowrap="nowrap" width="8%" align="center"><font size="2"><input type="text" id="ylt_rlzcq1" name="ylt_rlzcq1" value="${yjrbph.ylt_rlzcq1}" onafterpaste="value=value.replace(/[^\d\.]/g,'')" style="width:80px;text-align:right" onfocus="javascript:this.select();" onblur="on_blur(this.value,this.id)" onkeydown="kuanghao(this.value,this.id)" onkeyup="on_keypress('ylt_rlwgq1');"></font> </td> </tr><tr> <th nowrap="nowrap" width="8%" background="<c:url value="/images/head.gif"/>"><font size="2">1#入炉进口矿</font></th> <td nowrap="nowrap" width="8%" align="center"><font size="2"><input type="text" id="ylt_rlwgq1" name="ylt_rlwgq1" value="${yjrbph.ylt_rlwgq1}" onafterpaste="value=value.replace(/[^\d\.]/g,'')" style="width:80px;text-align:right" onfocus="javascript:this.select();" onblur="on_blur(this.value,this.id)" onkeydown="kuanghao(this.value,this.id)" onkeyup="on_keypress('ylt_glpm1');"></font> </td> </tr><tr> <th nowrap="nowrap" width="8%" background="<c:url value="/images/head.gif"/>"><font size="2">1#高炉喷煤量</font></th> <td nowrap="nowrap" width="8%" align="center"><font size="2"><input type="text" id="ylt_glpm1" name="ylt_glpm1" value="${yjrbph.ylt_glpm1}" onafterpaste="value=value.replace(/[^\d\.]/g,'')" style="width:80px;text-align:right" onfocus="javascript:this.select();" onblur="on_blur(this.value,this.id)" onkeyup="on_keypress('ylt_rljhyj2_sj');"></font> </td> </tr><tr> <th nowrap="nowrap" width="8%" background="<c:url value="/images/head.gif"/>"><font color="red" size="2">1#炉铁合计</font></th> <td nowrap="nowrap" width="8%" align="center"><font size="2"><input type="text" id="ylt_thj1" name="ylt_thj1" value="${yjrbph.ylt_thj1}" onafterpaste="value=value.replace(/[^\d\.]/g,'')" style="width:80px;text-align:right" onfocus="javascript:this.select();" onblur="on_blur(this.value,this.id)" onkeyup="on_keypress('lt_zk');"></font> </td> </tr><tr> <th nowrap="nowrap" width="8%" background="<c:url value="/images/head.gif"/>"><font color="red" size="2">1#炉矿耗</font></th> <td nowrap="nowrap" width="8%" align="center"><font size="2"><input type="text" id="ylt_kh1" name="ylt_kh1" value="${yjrbph.ylt_kh1}" onafterpaste="value=value.replace(/[^\d\.]/g,'')" style="width:80px;text-align:right" onfocus="javascript:this.select();" onblur="on_blur(this.value,this.id)" onkeyup="on_keypress('lt_zk');"></font> </td> </tr></table></from><script type="text/javascript">function kuanghao(value, id) { if (event.keyCode == 13) { var yltkh1 = new Array('ylt_rlsjk1', 'ylt_rlzcq1', 'ylt_rlwgq1', 'ylt_rlets1'); for (var i = 0; i < ylt.lenght; i++) { if (yltkh1[i] == id) { var ylt_rlsjk1 = $("#ylt_rlsjk1").val(); var ylt_rlzcq1 = $("#ylt_rlzcq1").val(); var ylt_rlwgq1 = $("#ylt_rlwgq1").val(); var ylt_rlets1 = $("#ylt_rlets1").val(); var ylt_thj1 = $("#ylt_thj1").val(); var sum = (ylt_rlsjk1 + ylt_rlzcq1 + ylt_rlwgq1 + ylt_rlets1 ) / ylt_thj1 * 1000 alert(sum); $("#ylt_kh1").val(sum); alert($("#ylt_kh1").val(sum)); } } } }</script>
我想实现页面文本框输入数字时,回车计算出矿耗.
但是现在页面输数回车没没有反映啊,后台也没有动作.
[解决办法]
event.keyCode IE only
$("#ylt_thj1").val(); 是字符串
var ylt_thj1 =parseInt( $("#ylt_thj1").val(),10);
