我在IE下可以运行的JS脚本(check.点击事件)~在火狐上为什么没用呢?请大侠帮忙

解决方案 »

  1.   


    function changeStatus(obj)

    var txt=window.document.getElementById("cuxiaoPrice");
    if(obj.checked)  { 
    txt.value="";
    txt.disabled=false; 

    } else { 

    if(!obj.checked){
    txt.value=0;
    }
    txt.disabled=true; 
     }
    这是JS代码,意思就是如果checkBox被选中,文本框就可以输入,可我在火狐上点checkBox没效果
      

  2.   

    var txt=window.document.getElementById("cuxiaoPrice");
    //txt是文本框,
      

  3.   

    浏览器不一样导致的JS脚本不能正常运行,这很正常;
    就是同一种浏览器,比如IE,版本不一样,同样的JS脚本,在IE7中就能用而到IE6上就不行。
      

  4.   

    在火狐下选中check文本框还是默认的不可写
    有什么办法么?
      

  5.   

    没办法,FF下文本框disable的属性是只读的
      

  6.   

    你用css控制下显示和不显示把,改属性是改不了的
      

  7.   

    var txt=window.document.getElementById("cuxiaoPrice");改为:var txt=document.getElementById("cuxiaoPrice");
      

  8.   

    <script language="JavaScript"  type="text/javascript">
    obj.setAttribute("disabled","disabled");  
    obj.removeAttribute("disabled"); 
    //...
    </script>
      

  9.   

    function changeStatus(obj){ 
        var txt=document.getElementById("cuxiaoPrice");
        if(obj.checked) { 
            txt.value="";
            txt.removeAttribute("disabled");
            
        }
        else {         
            txt.value=0;
            txt.setAttribute("disabled","disabled");
         }
    }
      

  10.   


    <html>
    <head>
    <script>function changeStatus(obj) {
        var txt = document.getElementById("cuxiaoPrice");
        if(obj.checked) { 
            txt.value="";
            txt.disabled=false; 
        } else {    
            if(!obj.checked){
                txt.value=0;
            }
            txt.disabled=true; 
         }
    }
    </script>
    </head>
    <body>
    <input type="text" id="cuxiaoPrice" name="cuxiaoPrice"/>
    <input type="checkbox" id="cuxiaoPrice" name="cuxiaoPrice" onclick="changeStatus(this)"/>
    </body>
    </html>
      

  11.   


    function changeStatus(obj)

    var txt=window.document.getElementById("cuxiaoPrice");
    if(obj.checked)  { 
    txt.value="";
    txt.disabled=false; 

    } else { 

    if(!obj.checked){
    txt.value="0";
    }
    txt.disabled=true; 
     }
    //文本框
    <s:textfield id="cuxiaoPrice" name="product.promotionPrice" cssClass="txt_height" value="0" cssStyle="width:50px;"  onkeyup="value=value.replace(/[^\d.]/g, '')"  disabled="true"/>
    }上面高手说的不对啊~还是不行~
      

  12.   

    有什么办法可以行呢??我源代码已经贴上去了~在IE6.0下可以运行,在火狐下点击check一点反应都无,求救!!
      

  13.   

    另外,把标签换成html标签试试,那段代码我在ff中测试通过,你要看一下<s:textfield 标签被编译转换成html标签后有什么不同的地方
      

  14.   

    ie和火狐的事件处理机制不一样,你要重document中获取事件对象,然后根据判断对象中的属性来判断是什么浏览器然后处理业务