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 6228891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:28:00+00:00 2026-05-24T09:28:00+00:00

I have 5 sets of radio buttons, set1, set2, set3, set4, set5. Values are

  • 0

I have 5 sets of radio buttons, set1, set2, set3, set4, set5. Values are yes/no for each.

I need the number of yes’s to be shown in a hidden text box.. ie 1,2,3,4 or 5, and obviously change as people select different options..

<input type="radio" name="set1" id="set1_no" value="no">
<input type="radio" name="set1" id="set1_yes" value="yes">

<input type="radio" name="set2" id="set2_no" value="no">
<input type="radio" name="set2" id="set2_yes" value="yes">

<input type="radio" name="set3" id="set3_no" value="no">
<input type="radio" name="set3" id="set3_yes" value="yes">

<input type="radio" name="set4" id="set4_no" value="no">
<input type="radio" name="set4" id="set4_yes" value="yes">

<input type="radio" name="set5" id="set5_no" value="no">
<input type="radio" name="set5" id="set5_yes" value="yes">


<input type="hidden" name="number_of_yes" value="" readonly="readonly">
  • 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-05-24T09:28:01+00:00Added an answer on May 24, 2026 at 9:28 am

    Given that you are setting a hidden field (which doesn’t need to be readonly, by the way, since it is…well…hidden) I would probably only update it onsubmit of the <form>. If you really need it updated as you go just use an onclick or onchange instead. However you trigger it, you can try something like this:

    yourForm.onsubmit = setYesCount;
    
    function setYesCount() {
      var count = 0;
    
      // could use yourForm.getElementsByTagName(),
      // but since the OP didn't provide surrounding HTML:
      var els = document.getElementsByTagName("input");
      for (var i=0; i < els.length; i++) {
        if (els[i].type === "radio" && els[i].checked && els[i].value === "yes")
          count++;
      }
      // add an id attribute to the hidden input
      // for the following to work
      document.getElementById("number_of_yes").value = count;
    }
    

    (And if I don’t say it somebody else will: you could do this in one or two lines with jQuery.)

    EDIT: jQuery version – again I’ve put it on the form’s submit event (I’m assuming you have a form and can fill in the id). You can change this to a change or click event if needed.

    $(document).ready(function() {
      $("#yourFormsId").submit(function() {
             $('input[name="number_of_yes"]').val(
                $('input:checked[type="radio"][value="yes"]').length);
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have the number of 'yes's' selected from a set of radio
I have a page with several sets of radio buttons that are used to
I'm producing a page dynamically and I have several sets of radio buttons. I
I have several sets of radio buttons, the last one of which is an
I am new to html and css. I have 3 sets of radio buttons.
I have two sets of radio buttons. The idea is to use a label
I have sets of strings in a database. Each set will have less than
I have sets of controllers which are each used for each authorization type. For
I have three sets of checkboxes (serviceA, B & C) with 5 checkboxes each,
I have a UIToolbar that needs three buttons in a radio style, meaning that

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.