把js代码放到html标签后面试试,
firefox的加载机制和ie不一样,

解决方案 »

  1.   

    <html> 
    <head> 
    <title>Elements </title> 
    <script type='text/javascript'> 
    function valid(){ 
        var total = 0; 
        var friends = document.form1.elements; 
        for (var i=0; i <friends.length; i++) 
            { 
            if (friends[i].name == "friends" && friends[i].checked) 
                { 
                total++; 
                } 
            } if (total == 0){ 
    document.form1.delete1.disabled = true; 
    document.form1.update.disabled = true; 

    else if (total == 1){ 
    document.form1.delete1.disabled = false; 
    document.form1.update.disabled = false; 

    if (total >= 2){ 
    document.form1.delete1.disabled = true; 
    document.form1.update.disabled = false; 


    function selectAll(){ 
    var friends = document.form1.elements; 
    if (document.form1.all.checked == true) 

    for (var i=0; i <friends.length; i++) 

    if (friends[i].name == "friends") 

     friends[i].checked = true; 



    else 

    for (var i=0; i <friends.length; i++) 

    if (friends[i].name == "friends") 

     friends[i].checked = false; 




    function selectReversed(){ 
    var friends = document.form1.elements; 
      for (var i=0; i <friends.length; i++) 

    if (friends[i].name == "friends") 

    friends[i].checked = !friends[i].checked; 



    </script> 
    </head> <body onload="valid();"> 
      <form name="form1" method="get" action=""> 
      <input type="button" name="delete1" value="全选"> 
      <input type="checkbox" name="all" onclick="selectAll();valid();" /> | 
      <input type="button" name="update" value="反选"> 
      <input type="checkbox" name="reversed" onclick="selectReversed();valid();" /> | 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      <input type="checkbox" name="friends" onclick="valid();" /> 
      </form> 
    </body> 
    </html> 
    不要把名字定义为delete 这个是javascript的关键字 改成delete1就可以了
      

  2.   

    哎,取啥名不好取个名字叫delete
    ……
    害得我看了半天:
    <html>
    <head>
    <title>Elements </title>
    <script>
    function valid(){
    var total = 0;
    var friends = document.form1.elements;
    for (var i=0; i <friends.length; i++)
    {
    if (friends[i].name == "friends" && friends[i].checked)
    {
    total++;
    }
    }
    alert(total);//check total value
    if (total == 0){
    document.form1.delete1.disabled = true;
    document.form1.update.disabled = true;
    }
    else if (total >= 1){
    document.form1.delete1.disabled = false;
    document.form1.update.disabled = false;
    }}
    function selectAll(){
    var friends = document.form1.elements;
    if (document.form1.all.checked == true)
    {
    for (var i=0; i <friends.length; i++)
    {
    if (friends[i].name == "friends")
    {
     friends[i].checked = true;
    }
    }
    }
    else
    {
    for (var i=0; i <friends.length; i++)
    {
    if (friends[i].name == "friends")
    {
     friends[i].checked = false;
    }
    }
    }
    }
    function selectReversed(){
    var friends = document.form1.elements;
      for (var i=0; i <friends.length; i++)
    {
    if (friends[i].name == "friends")
    {
    friends[i].checked = !friends[i].checked;
    }
    }
    }
    </script>
    </head><body >
      <form name="form1" method="get" action="">
      <input type="button" name="delete1" value="全选">
      <input type="checkbox" name="all" onclick="selectAll();" /> ¦
      <input type="button" name="update" value="反选">
      <input type="checkbox" name="reversed" onclick="selectReversed();valid();" /> ¦
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      <input type="checkbox" name="friends" onclick="valid();" />
      </form>
    </body>
    </html>
      

  3.   

    不要使用 name="updae" 和 id="update"