Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Back to articles

Select all checkboxes in form

Here is a piece of code that will allow you to select all checkboxes in specified form, like you can do it in your email account  - select all emails. It takes form id as parameter

<script type='text/javascript'>
function select_allch(id)
{
    var form = document.getElementById(id);
    var inputs = form.getElementsByTagName('input');
    var input;
    for(var i = 0; i < inputs.length; i++)
    {
        input = inputs[i];
        input.checked = true;
    }
}
</script>
<a href='javascript:void(0)' onclick='select_allch("check_form")'>Select all</a>
<form action='' method='post' id='check_form'>
<p>Check this <input type='checkbox' name='check[]'/></p>
<p>Check this <input type='checkbox' name='check[]'/></p>
<p>Check this <input type='checkbox' name='check[]'/></p>
<p>Check this <input type='checkbox' name='check[]'/></p>
<p>Check this <input type='checkbox' name='check[]'/></p>
<p>Check this <input type='checkbox' name='check[]'/></p>
<p>Check this <input type='checkbox' name='check[]'/></p>
<p>Check this <input type='checkbox' name='check[]'/></p>
<p><input type='submit' value='Submit'/></p>
</form>

And here is an example:

Select all

Check this

Check this

Check this

Check this

Check this

Check this

Check this

Check this


You may also be interested in:

Powered by BlogAlike.com

blog comments powered by Disqus