<select multiple="true" id="sel" name="sel">
<option>one</option>
<option>two</option>
<option>three</option>
<option>four</option>
<option>five</option>
</select>
<script>
var oSel = document.getElementById("sel");
for(var i=0; i<oSel.options.length; i++){
oSel.options[i].selected = true;
}
</script>

解决方案 »

  1.   

    <html>
    <head><title></title></head>
    <body>
    <script type='text/javascript'>
    function checkall(cb,f)
    {
      for(var i=0;i<f.elements.length;i++)
      {
        var e=f.elements[i];
        if (e.name!=cb.name)
          e.checked=cb.checked;
      }
    }
    </script>
    <form name='form1'>
    <input type='checkbox' name='chkall' onclick='checkall(this,this.form)'/>全部选择<br/>
    <input type='checkbox' />1<br/>
    <input type='checkbox' />2<br/>
    <input type='checkbox' />3<br/>
    <input type='checkbox'  />4<br/>
    <input type='checkbox'/>5<br/>
    <input type='checkbox'  />6<br/>
    </form>
    </body>
    </html>
    这个效果??
      

  2.   

    <html>
    <head><title></title></head>
    <body>
    <script type='text/javascript'>
    function checkall(obj)
    {
      for(var i=0;i<obj.elements.length;i++)
      {
        var e=obj.elements[i];
        if (e.type==checkbox)
          e.checked=true;
      }
    }
    </script>
    <form name='form1'>
    <input type='checkbox' name='chkall' onclick='checkall(this.form)'/>全部选择<br/>
    <input type='checkbox' />1<br/>
    <input type='checkbox' />2<br/>
    <input type='checkbox' />3<br/>
    <input type='checkbox'  />4<br/>
    <input type='checkbox' />5<br/>
    <input type='checkbox'  />6<br/>
    </form>
    </body>
    </html>这是实现点全选按钮 实现全部选择的功能