焦点丢失怎么捕捉 每一个文本框里边都写上一个相同的onchange或者onblur事件,这样每次输入完了,都可以去做一边求和的操作,这样每次都会将合计值放到你的合计框里边。不就可以了吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 哦,忘了说了,我是用onKeyDown和onBlur来触发那个function的,但是onBlur好象不起作用. andymu077(明治佐玛戒--秀曼) 谢谢,onChange可以了,再请问一下,当鼠标点中一个输入框后,怎么能让里面的内容全选.再次感谢!! 我觉得你不应该用onKeyDown,最好使用一下onKeyUp来做,我下边试着做了一个:<html><head> <title>Untitled</title><Script language="javascript"><!--function fncSum(){ var obj=document.all; var temp=0 for (i=0;i<obj.txt.length;i++){ temp=Number(temp)+Number(obj.txt(i).value); } obj.txtSum.value=Number(temp);}//--></Script></head><body><form><input type="text" name="txt" value="" onKeyUp="fncSum()"><br><input type="text" name="txt" value="" onKeyUp="fncSum()"><br><input type="text" name="txt" value="" onKeyUp="fncSum()"><br><input type="text" name="txt" value="" onKeyUp="fncSum()"><br><input type="text" name="txt" value="" onKeyUp="fncSum()"><br><input type="text" name="txt" value="" onKeyUp="fncSum()"><br><input type="text" name="txt" value="" onKeyUp="fncSum()"><br><input type="text" name="txt" value="" onKeyUp="fncSum()"><br><input type="text" name="txt" value="" onKeyUp="fncSum()"><br><center>SUM:<input type="text" name="txtSum" value="0"></center></form></body></html> <html><head> <title>Untitled</title><Script language="javascript"><!--function fncSum(){ var obj=document.all; var temp=0 for (i=0;i<obj.txt.length;i++){ temp=parseFloat(temp)+parseFloat(obj.txt(i).value); } obj.txtSum.value=parseFloat(temp);}function fncSelect(obj){//window.event.shiftKey=true;//alert(window.event.shiftKey)this.select();}//--></Script></head><body><form><input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br><center>SUM:<input type="text" name="txtSum" value="0"></center></form></body></html> andymu077(明治佐玛戒--秀曼) 的可以了.thk 我还用的onkeydown,onkeyup的话敲回车不起作用了,我还是要保留回车相当于敲了个tab结帖. 一个比较麻烦的办法:<html><head> <title>Untitled</title><Script language="javascript"><!--function fncSum(No){ var obj=document.all; var temp=0 if (window.event.keyCode==13){ for (i=0;i<obj.txt.length;i++){ temp=Number(temp)+Number(obj.txt(i).value); if (No==i-1){ obj.txt(i).focus(); } } } obj.txtSum.value=Number(temp);}function fncSelect(obj){//window.event.shiftKey=true;//alert(window.event.shiftKey)this.select();}//--></Script></head><body><form><input type="text" name="txt" value="" onKeyUp="fncSum(0)" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum(1)" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum(2)" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum(3)" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum(4)" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum(5)" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum(6)" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum(7)" onclick="this.select();"><br><input type="text" name="txt" value="" onKeyUp="fncSum(8)" onclick="this.select();"><br><center>SUM:<input type="text" name="txtSum" value="0"></center></form></body></html> myeclipse中jquery导入后没有效果 文章标签提取怎么弄? ajax阻止表单跳转 按钮怎么让它点击一次后,不能再点击了? 怎么得知你浏览页面的IE是不是当前窗口? html调用js文件一问?? 一个正则表达式写法? 关于XP IE6 创建 Word2000 错误 Automation 错误? 紧急!! 100 分 :为什么进行强制转换后,结果不正确 extjs面板加载百度地图第一次失败,第二次才成功 target 问题 问一个播放器的问题
<html>
<head>
<title>Untitled</title>
<Script language="javascript">
<!--
function fncSum(){
var obj=document.all;
var temp=0
for (i=0;i<obj.txt.length;i++){
temp=Number(temp)+Number(obj.txt(i).value);
}
obj.txtSum.value=Number(temp);}//-->
</Script>
</head>
<body>
<form>
<input type="text" name="txt" value="" onKeyUp="fncSum()"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()"><br>
<center>
SUM:<input type="text" name="txtSum" value="0">
</center>
</form>
</body>
</html>
<head>
<title>Untitled</title>
<Script language="javascript">
<!--
function fncSum(){
var obj=document.all;
var temp=0
for (i=0;i<obj.txt.length;i++){
temp=parseFloat(temp)+parseFloat(obj.txt(i).value);
}
obj.txtSum.value=parseFloat(temp);}function fncSelect(obj){
//window.event.shiftKey=true;
//alert(window.event.shiftKey)
this.select();
}//-->
</Script>
</head>
<body>
<form>
<input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum()" onclick="this.select();"><br>
<center>
SUM:<input type="text" name="txtSum" value="0">
</center>
</form>
</body>
</html>
我还用的onkeydown,onkeyup的话敲回车不起作用了,我还是要保留回车相当于敲了个tab
结帖.
<html>
<head>
<title>Untitled</title>
<Script language="javascript">
<!--
function fncSum(No){
var obj=document.all;
var temp=0
if (window.event.keyCode==13){
for (i=0;i<obj.txt.length;i++){
temp=Number(temp)+Number(obj.txt(i).value);
if (No==i-1){
obj.txt(i).focus();
}
}
}
obj.txtSum.value=Number(temp);
}function fncSelect(obj){
//window.event.shiftKey=true;
//alert(window.event.shiftKey)
this.select();
}//-->
</Script>
</head>
<body>
<form>
<input type="text" name="txt" value="" onKeyUp="fncSum(0)" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum(1)" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum(2)" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum(3)" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum(4)" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum(5)" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum(6)" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum(7)" onclick="this.select();"><br>
<input type="text" name="txt" value="" onKeyUp="fncSum(8)" onclick="this.select();"><br>
<center>
SUM:<input type="text" name="txtSum" value="0">
</center>
</form>
</body>
</html>