Oct 5 2007

Check all checkboxes (javascript)

javascript checkbox select all

Here is the javascript code for checking all the checkboxes inside an html document.

<script>
function checkAll()
{

var inputs = document.getElementsByTagName(’input’);
var checkboxes = [];
for (var i = 0; i < inputs.length; i++) {

  if (inputs[i].type == ‘checkbox’) {
inputs[i].checked =true;

}
}
}

</script>

TAGS:

2 Comments on this post

Trackbacks

  1. amanda said:

    this was extremely helpful, thanks for posting!

    July 8th, 2008 at 7:56 pm
  2. Sajan said:

    Hi, the code was really helpul. I would like to know something more about this. I am trying to put in code where if I select all the checkboxes the selectall checkbox should automatically get selected.
    For eg: I have five rows in a table with check option. I click select all and the above code works. Now can u help me such that when I click each of the checkboxes for these 5 rows the above select all checkbox gets selected. The reverse of what happened with the query. Plz help me out..

    August 12th, 2008 at 10:38 am

LEAVE A COMMENT

Subscribe Form

Subscribe to Blog

Sponsors

    Advt on sajithmr.com
    Advt on sajithmr.com
    Itslife Online
    Advt on sajithmr.com

Recent Comments

  • Binny V A: Thanks for the post - love the picture ;-)
  • TheAnand: A lot of people are seeing errors with google video chat….is there any other software which has to be...
  • Alex: Wow, interresting analysis you have done! I’m trying to run GoogleVoiceAndVideoSetup on linux, using...
  • Mella Fitriansyah: Nice plugin, I will try to add this plugin in my blog…
  • Mella Fitriansyah: Nice Info, Sir i will reading your another post success for you

Recent Readers

JOIN MY COMMUNITY!

Recent Posts