首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

帮小弟我看小弟我的代码 为什么总是NaN

2012-02-28 
帮我看我的代码 为什么总是NaN为什么最后alert最后的值是NaN我也做类型转换了我是超超级菜鸟应该得到的是

帮我看我的代码 为什么总是NaN
为什么最后alert最后的值是NaN   我也做类型转换了   我是超超级菜鸟   应该得到的是选中框的值的和啊.

<button   onClick= "add() "> add </button>
<button   onClick= "del() "> del </button>
<table   id= "t1 "   border= "1 "> </table>
<script   language= "JavaScript ">
function   add(){
var   tt=t1.insertRow();
tt.insertCell().innerHTML   =   ' <input   type= "checkbox "   name= "tt "> ';
tt.insertCell().innerHTML   =   ' <input   name= "y "   type= "text "   /> ';
}
function   del(){
var   s;
var   t;
var   c   =   document.getElementsByName( 'tt ');
var   b=document.getElementsByName( 'y ')
for(var   i=0;   i <c.length;   i++){
if(c[i].checked)
t=b[i].value;
s+=parseFloat(t);

}
alert(s);
}
</SCRIPT>


[解决办法]
初始化 var s=0;

热点排行