Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:50:32+00:00 2026-06-17T05:50:32+00:00

I’ve got a function in JS that check all my checkboxes in a form:

  • 0

I’ve got a function in JS that check all my checkboxes in a form:

function CheckAll(chk){
    for (i = 0; i < chk.check.length; i++)
        if (chk.All.checked==true){
            chk.check[i].checked = true;
            chk.check[i].disabled = true;
        }
        else {
            chk.check[i].disabled = false;
            chk.check[i].checked = false;
        }
}

I’ve recently added some radio buttons to my form, and my question is: will this function activate ALL my radio buttons too (I know that only one radio button can be selected, but I’m not sure how this works in a script like that..)?

Here you can find my form code:

<form name='MyForm'>
    <b>This is my Simple Form</b></br>
    </br>
    <input type='radio' name='parameter' value='ONE' checked='checked' />ONE<br/>
    <input type='radio' name='parameter' value='TWO' />TWO<br/>
    <input type='radio' name='parameter' value='THREE' />THREE<br/>
    <input type='radio' name='parameter' value='FOUR' />FOUR<br/>
    <input type='radio' name='parameter' value='FIVE' />FIVE<br/>
    <input type='radio' name='parameter' value='SIX' />SIX<br/>
    <input type='radio' name='parameter' value='SEVEN' />SEVEN<br/>
    <script>
        document.write("</br>");
        var count
        var check_value = new Array()
        check_value[0] = "001"
        check_value[1] = "002"
        check_value[2] = "003"
        check_value[3] = "004"
        for(count in check_value){
            var checkbox = "<input type='checkbox' name='check' value='"+check_value[count]+"' />"
            document.write(checkbox + check_value[count] + "  ");
        }
        document.write("<input type='checkbox' name='All' value='All' onClick='CheckAll(document.MyForm);' /> All");
    </script>
    </br>
    </br>
    <input type=button value='Ok' onClick='foo(document.MyForm);'>
</form>

If this don’t work as I want, how can I solve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:50:33+00:00Added an answer on June 17, 2026 at 5:50 am

    Testing is as simple as that : http://jsfiddle.net/yk9uD/

    Content :

    <form name='MyForm'>
        <b>This is my Simple Form</b></br>
        </br>
        <input type='radio' name='parameter' value='ONE' checked='checked' />ONE<br/>
        <input type='radio' name='parameter' value='TWO' />TWO<br/>
        <input type='radio' name='parameter' value='THREE' />THREE<br/>
        <input type='radio' name='parameter' value='FOUR' />FOUR<br/>
        <input type='radio' name='parameter' value='FIVE' />FIVE<br/>
        <input type='radio' name='parameter' value='SIX' />SIX<br/>
        <input type='radio' name='parameter' value='SEVEN' />SEVEN<br/>
        <script>
          function CheckAll(chk){
      for (i = 0; i < chk.check.length; i++) {
            if (chk.All.checked==true){
                chk.check[i].checked = true;
                chk.check[i].disabled = true;
            }
            else {
                chk.check[i].disabled = false;
                chk.check[i].checked = false;
            }
    }
    }
            document.write("</br>");
            var count;
            var check_value = new Array()
            check_value[0] = "001"
            check_value[1] = "002"
            check_value[2] = "003"
            check_value[3] = "004"
            for(count in check_value){
                var checkbox = "<input type='checkbox' name='check' value='"+check_value[count]+"' />"
                document.write(checkbox + check_value[count] + "  ");
            }
            document.write("<input type='checkbox' name='All' value='All' onClick='CheckAll(document.MyForm);' /> All");
        </script>
        </br>
        </br>
        <input type=button value='Ok' onClick='foo(some var);'>
    </form>
    

    And the answer to the question is : No, it won’t select all radio buttons.

    The reason is that your code iterates only over inputs whose name is check :

    for (i = 0; i < chk.check.length; i++) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.