要用parseInt转换一下数据类型

解决方案 »

  1.   

    theall+=parseint(document.getElementById("zj"+i).value);这样写么?还是一样啊。。得不到效果
      

  2.   

    要求得多个框中别人输入的值的总合。
    //统一把input的name 属性明名为(name='pricename')
    var allprice = document.getElementsByName('pricename');//为一数组按数组操作获得所有input框输入数据的一个数组剩下的就好办了
      

  3.   

    如果把NAME值写成一样的话,那提交的时候不是不能取值了?
      

  4.   

    theall=0;
    allprice=document.getElementById("hj").value; //下一行的NUM是求和的总个数。。
    for(i=1;i <=num;i++){
    theall+=document.getElementById("zj"+i).value;
    theall=theall; // 我想知道 ,你这句话是什么意思 ?你自己知道是什么意思不 ?
    alert(theall);
    }
    allprice=theall;//这里是把结果赋给下一个框中 【这就是付给input值么?搞清楚好不好,allprice是个变量,不是对象也不是对象的属性,而是对象的属性值!】
    ========这个社会都做了什么? ==================>>>>>>>>>theall=0;
    for(i=1;i <=num;i++){
    theall+=document.getElementById("zj"+i).value;
    }
    document.getElementById("hj").value=theall;
      

  5.   

    写详细点把
    //统一把input的name 属性明名为(name='pricename') 
    function sumprice(){
    var allprice = document.getElementsByName('pricename');//为一数组按数组操作 
    var sum =0;
        for(var i =0;i<allprice.length;i++){
    sum = sum + parseInt(allprice[i].value);
    } alert(sum);
    }//html
        <input type="text"  name="pricename"     />
                 <input type="text" name="pricename"    />
                <input type="button" value="testtr"   onclick="sumprice()" />
      

  6.   

    可以写几个
     <input type="hidden" name="" id=""/>
    再用js控制下不就行了 
      

  7.   

    可以不用这个
    parseInt  
    建议用这个吧Number
    不然的话。可能得不到你想要的结果
      

  8.   

    theall=0; 
    allprice=document.getElementById("hj").value; //下一行的NUM是求和的总个数。。 
    for(i=1;i <=num;i++){ 
    theall+=Number(document.getElementById("zj"+i).value); 
    theall=theall; 
    alert(theall); 

    document.getElementById("hj").value=theall; //这里是把结果赋给下一个框中
      

  9.   

    // 结果赋给下一个框好像这样了
    document.getElementById("hj").value=theall;