代码:
function calculator()
{
         var ld_datetime=parseInt(document.getElementById('ld_datetime').value);
         if(ld_datetime==1)
{
document.getElementById('ld_price').value=150;
}
else if(ld_datetime==2)
{
document.getElementById('ld_price').value=200;
}
else if(ld_datetime>=3)
{
document.getElementById('ld_datetime').value=0;
document.getElementById('ld_price').value=0;
alert("租用天数超过3天!");
}
}在ie下可以使用,在ff下不能计算,求解

解决方案 »

  1.   

    <html> 
    <head> 
    <meta http-equiv="contentType" content="text/html;charset=utf-8"> 
    <script src="jquery-1.4.2.min.js"></script> 
    <script> 
    function calculator()
    {
    var ld_datetime=parseInt(document.getElementById('ld_datetime').value);
    if(ld_datetime==1)
        {
        document.getElementById('ld_price').value=150;    
        }
        else if(ld_datetime==2)
        {
        document.getElementById('ld_price').value=200;    
        }
        else if(ld_datetime>=3)
        {
        document.getElementById('ld_datetime').value=0;
        document.getElementById('ld_price').value=0;
        alert("租用天数超过3天!");    
        }
    }</script> 
    </head> 
    <body> 
    <input type="text" id="ld_datetime" />
    <input type="text" id="ld_price" />
    <input type="button" onclick="calculator()" value="test" />
    </body> 
    </html>
      

  2.   

    <html> 
    <head> 
    <meta http-equiv="contentType" content="text/html;charset=utf-8"> 
    <script src="jquery-1.4.2.min.js"></script> 
    <script> 
    function calculator()
    {
        var ld_datetime=parseInt(document.getElementById('ld_datetime').value);
        if(ld_datetime==1)
        {
        document.getElementById('ld_price').value=150;    
        }
        else if(ld_datetime==2)
        {
        document.getElementById('ld_price').value=200;    
        }
        else if(ld_datetime>=3)
        {
        document.getElementById('ld_datetime').value=0;
        document.getElementById('ld_price').value=0;
        alert("租用天数超过3天!");    
        }
    }
    </script> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head> 
    <body> 
    <table>
    <form action="OrderSave.asp?Action=SaveEdit&Rect=Jing" method="post" name="editAboutForm" id="editAboutForm" onKeyUp="calculator()" onMousemove="calculator()">
    <tr>
    <td height="30" align="right"><b>领队租用:</b></td>
    <td ></td>
    </tr>
    <tr bgcolor='#EBF2F9' onMouseOver="this.style.backgroundColor='#FFFFFF'" onMouseOut="this.style.backgroundColor=''" style='cursor:hand'>
    <td height="30" align="right">领队性别:</td>
    <td ><input type="radio" name="ld_sex" value="男">
    男&nbsp;
    <input type="radio" name="ld_xex" value="女">女</td> </tr>
    <tr bgcolor='#EBF2F9' onMouseOver="this.style.backgroundColor='#FFFFFF'" onMouseOut="this.style.backgroundColor=''" style='cursor:hand'>
    <td height="30" align="right">租用天数:</td>
    <td ><img src="/styles/images/order_cart_jian.gif" onclick ="if(document.getElementById('ld_datetime').value<=0) {alert('天数不得小于0!')} else{document.getElementById('ld_datetime').value = parseInt(document.getElementById('ld_datetime').value)-1}" />&nbsp;<input type="text" name="ldatetime" id="ld_datetime" class="input1" size="5" readonly="readonly" value="0" style="width:40px;border:0;color:red;" />天&nbsp;<img onclick = "document.getElementById('ld_datetime').value = parseInt(document.getElementById('ld_datetime').value)+1" src="/styles/images/order_cart_jia.gif" /></td>
     </tr>
    <tr bgcolor='#EBF2F9' onMouseOver="this.style.backgroundColor='#FFFFFF'" onMouseOut="this.style.backgroundColor=''" style='cursor:hand'>
    <td height="30" align="right">租用领队费用:</td>
    <td ><input name="price"  id="ld_price" type="text" class="input1" size="5" readonly="readonly" value="0" style="width:40px;border:0;color:red;"/>元</td>
    </tr>
     </form>           
    </table>
    </body> 
    </html> 发下整的代码吧。 谢谢 cj205 的热心解答
      

  3.   

    同学你是想什么时候调用你那个calculator函数,你在form标签上写了 onmousemove和onkeyup没有用的。。你可能是想在点击租用天数的时候调用calculator吧,去那俩图片上写onclick试试。。还有别在标签里写js吧。。写个函数让它调么。去w3cschool学学基础的吧
      

  4.   

    我晕,因为想要在键盘输入书之后变动结果还有当点击图片后更改数值进而也能变动结果,这里的功能在ie里完全可用,就是在那个计算结果租用领队费用:</td>
    <td ><input name="price"  id="ld_price" type="text" class="input1" size="5" readonly="readonly" value="0" style="width:40px;border:0;color:red;"/>元</td>
    </tr>这里的数值在ff下不能变化,而在ie下可以的。  基础太差,但是要用到了就写,写得不规范就从自己写的例子里学习下,这个也没有办法 不可能看了就吃饱了撑个胖子呀 。
      

  5.   

    from里的onKeyUp="calculator()" onMousemove="calculator()"去掉。calculator()在加减图片的click时间里执行
      

  6.   

    其实问题在于你的HTML上
    你把form和table的位置换下
    <form><table></table></form>绝对好了
      

  7.   

    测试了一下,找到原因了,将form和table调换位置,然后更重要的是,calculator设为from的点击事件,如下:<html> 
    <head> 
    <meta http-equiv="contentType" content="text/html;charset=utf-8"> 
    <script src="jquery-1.4.2.min.js"></script> 
    <script> 
    function calculator()
    {
        var ld_datetime=parseInt(document.getElementById('ld_datetime').value);
        if(ld_datetime==1)
        {
        document.getElementById('ld_price').value=150;    
        }
        else if(ld_datetime==2)
        {
        document.getElementById('ld_price').value=200;    
        }
        else if(ld_datetime>=3)
        {
        document.getElementById('ld_datetime').value=0;
        document.getElementById('ld_price').value=0;
        alert("租用天数超过3天!");    
        }
    }
    </script> 
    </head> 
    <body> 
    <form action="OrderSave.asp?Action=SaveEdit&Rect=Jing" method="post" name="editAboutForm" id="editAboutForm" onKeyUp="calculator()" onClick="calculator()">
    <table>
    <tr>
    <td height="30" align="right"><b>领队租用:</b></td>
    <td ></td>
    </tr>
    <tr bgcolor='#EBF2F9' onMouseOver="this.style.backgroundColor='#FFFFFF'" onMouseOut="this.style.backgroundColor=''" style='cursor:hand'>
    <td height="30" align="right">领队性别:</td>
    <td ><input type="radio" name="ld_sex" value="男">
    男&nbsp;
    <input type="radio" name="ld_xex" value="女">女</td> </tr>
    <tr bgcolor='#EBF2F9' onMouseOver="this.style.backgroundColor='#FFFFFF'" onMouseOut="this.style.backgroundColor=''" style='cursor:hand'>
    <td height="30" align="right">租用天数:</td>
    <td ><img src="/styles/images/order_cart_jian.gif" onclick ="if(document.getElementById('ld_datetime').value<=0) {alert('天数不得小于0!')} else{document.getElementById('ld_datetime').value = parseInt(document.getElementById('ld_datetime').value)-1}" />&nbsp;<input type="text" name="ldatetime" id="ld_datetime" class="input1" size="5" readonly="readonly" value="0" style="width:40px;border:0;color:red;" />天&nbsp;<img onclick = "document.getElementById('ld_datetime').value = parseInt(document.getElementById('ld_datetime').value)+1" src="/styles/images/order_cart_jia.gif" /></td>
     </tr>
    <tr bgcolor='#EBF2F9' onMouseOver="this.style.backgroundColor='#FFFFFF'" onMouseOut="this.style.backgroundColor=''" style='cursor:hand'>
    <td height="30" align="right">租用领队费用:</td>
    <td ><input name="price"  id="ld_price" type="text" class="input1" size="5" readonly="readonly" value="0" style="width:40px;border:0;color:red;"/>元</td>
    </tr>
    </table>
    </form>
    </body> 
    </html>
      

  8.   

    你的代码不符合标准呗
    <table>下只能是tbody thead tr 连直接套td都是个错误 何况你套了个form