JS全部选择/解除全部

in 前端设计

<script>
var checkflag="false";
function check(field){
if(checkflag=="false"){
for(i=0;i<field.length;i++){
        field[i].checked=true;}
        checkflag="true";
        return "解除全选"; }
 else {
        for(i=0;i<field.length;i++) {
        field[i].checked=false;}
        checkflag="false";
        return "选择全部";}}
</script>

<body>

<input type="button" name="SelectAll" value="全部选定" onclick="this.value=check(this.form)">

</body>

0 Comments

Leave a Reply

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>