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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:13:49+00:00 2026-06-08T02:13:49+00:00

All, I’ve got the following code to run through when a radio button is

  • 0

All,
I’ve got the following code to run through when a radio button is clicked to see if there is at least one entry in the group(s) choosen.

jQuery("input[type=radio]").click(function(event){
    alert('it is clicked');
    var num_questions = jQuery("#num_questions").val();
    var new_questions = parseInt(num_questions) + 1;
    for(var i=1; i<new_questions; i++){
        var radios = jQuery("input[type=radio]");
        var group  = radios.filter('[name=rating_value_'+i+']');
        if(group.filter(":checked").length==0){
            var answers_to_questions = "false";
            return false;
        }else{
            var answers_to_questions = "true";
            jQuery("#no_answers").html('');
        }
        //alert((group.filter(":checked").length)?"checked":"not checked");
    }
});

I get the alert so I know it’s getting there, however, the radio button is not being checked. When I remove this code however, it works fine. Any ideas why this would cause this to happen?

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-08T02:13:51+00:00Added an answer on June 8, 2026 at 2:13 am

    Returning false from an event handler prevents the default action for that event from occurring. In the case of a click on a radio button the default action is to select that radio button (and deselect the previously selected one in its group).

    “when a radio button is clicked to see if there is at least one entry in the group(s) choosen”

    I can’t understand what you’re trying to achieve here. “at least one” doesn’t make sense since only one radio at most can be checked in a given group. Less than one in a group can happen only if none were checked initially, because the user can’t un-check all radios in a given group.

    Having said that, in a general sense your code can be simplified:

    jQuery("input[type=radio]").click(function(event){
        var num_questions = jQuery("#num_questions").val(),
            new_questions = parseInt(num_questions, 10) + 1,
            radios = jQuery("input[type=radio]"),
            all_answered = true;
        for(var i=1; i<new_questions; i++){
            if(radios.filter('[name=rating_value_'+i+']:checked').length===0){
                all_answered = false;
                break;
                // return false;   <------ don't return false or it cancels the click
            }
        }
        if (!all_answered) {
            // a group was found that didn't have an answer selected
            // so do something
        } else
            jQuery("#no_answers").html('');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, If I run a query like the following: $qry = Select wrong_column from
All, See the code below: function menu() { this.menuitem=[]; this.submenu=[]; this.menuitem[0] = $('div#sivname1'); this.menuitem[1]
All, Say I have the following bit of code: select: function(start, end, allDay) {
All, I have the following code: $fetch = mysql_query(SELECT * FROM calendar_events where event_status='booked'
All, I have the following class so to check to see if the form
All, If I've go the following database fields/values: user_id field_name field_value 1 EventHour1 1
All -- I have these two methods in one of my classes: public static
All my code is here,quite simple,and I don't konw where it goes wrong. Person
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All of the sudden (at least so it seems), both Chrome and Firefox behave

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.