Pankajmittal’s Blog

August 4, 2011

Select all checkbox in a div or in grid

Filed under: Dot Net,Java Script,Tips — pankajmittal @ 10:34 am

<script language="javascript" type="text/javascript">
function SelectAllCheckboxes(spanChk) {         
            var collection = document.getElementById(‘GridData’).getElementsByTagName(‘INPUT’);
            for (var x = 0; x < collection.length; x++) {
                if (collection[x].type.toUpperCase() == ‘CHECKBOX’)
                    collection[x].checked = spanChk.checked;
            }
        }
    </script>

            <input id="chkAll"  runat="server" onclick="javascript:SelectAllCheckboxes(this);"
                type="checkbox" />     
            <b>Select All </b>

        <div class="innerrightarea" id="GridData">
            <input type="checkbox">
            <input type="checkbox">
            <input type="checkbox">
            <input type="checkbox">
            <input type="checkbox">
        </div>

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.