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

  • SEARCH
  • Home
  • 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 8984281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:03:45+00:00 2026-06-15T21:03:45+00:00

I have several checkboxes, each group with only one selectable component. An example of

  • 0

I have several checkboxes, each group with only one selectable component. An example of the checkboxes is below:

   <label class="checkbox inline">
        <input type="checkbox" id="question1option1" name="question1options" value="correct" onclick="SingleSelect('question1option',this)"> 1
    </label>
    <label class="checkbox inline">
        <input type="checkbox" id="question1option2" name="question1options" value="wrong" onclick="SingleSelect('question1option',this)"> 2
    </label>
    <label class="checkbox inline">
        <input type="checkbox" id="question1option3" name="question1options" value="wrong" onclick="SingleSelect('question1option',this)"> 3
    </label>
    <label class="checkbox inline">
        <input type="checkbox" id="question2option1" name="question2options" value="correct" onclick="SingleSelect('question2option',this)"> 1
    </label>
    <label class="checkbox inline">
        <input type="checkbox" id="question2option2" name="question2options" value="wrong" onclick="SingleSelect('question2option',this)"> 2
    </label>
    <label class="checkbox inline">
        <input type="checkbox" id="question2option3" name="question2options" value="wrong" onclick="SingleSelect('question2option',this)"> 3
    </label>

I have a javascript function that pulls out which radio button is selected by passing the radio button group (below), is there an equivalent someone can help me with to get the value of the checked checkbox (only one in each ‘group’) in a similar way please?

function getRadioValue (theRadioGroup)
    {
        for (var i = 0; i < document.getElementsByName(theRadioGroup).length; i++)
        {
            if (document.getElementsByName(theRadioGroup)[i].checked)
            {
                return document.getElementsByName(theRadioGroup)[i].value;
            }
        }
    }

Thanks in advance.

  • 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-15T21:03:46+00:00Added an answer on June 15, 2026 at 9:03 pm

    Actually, that same function will work if you correct your calls to SingleSelect or your markup; your markup is using names like question1options but your calls to SingleSelect are using names like question1option (without the s at the end). Fix that and it works: Live Example

    Obviously, though, checkboxes don’t automatically de-select other checkboxes with the same name when you click them (that’s what type="radio" is for). But I assume you know that. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several groups of checkboxes. Each group is contained in a div which
I have a page with several CheckBoxList controls with 4 checkboxes in each of
I have a form with several groupboxes, each containing controls several checkboxes. I want
I have several tabs. Each tab has several nested elements that contain checkbox input
On a page, I have several checkboxes, the id is different for each. The
I have a ListView containing several GridViewColumns. Several of the columns are checkboxes. Each
I have several PrimeFaces checkboxes on a page. If you click the master checkbox,
I have several forms, all which require a checkbox for each province/state. Therefore, I've
I have several checkboxes and I am trying to take a lazy approach of
I have several different numbers in a group that range in sizes and would

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.