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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:59:28+00:00 2026-05-26T22:59:28+00:00

I have a slight problem when it comes to validating my radio buttons. What

  • 0

I have a slight problem when it comes to validating my radio buttons. What suppose to happen is that if none of the radio buttons have been selected then it should come up with a message stating “click a radio button’ and if a radio button is selected it should output the message ‘radio button ‘+ btnNum + ‘ was selected’.

Instead what it is doing is that no matter if a radio button is selected or not it always displays the message ‘click a radio button’. I have been trying to figure this out for ages but can’t seem to find a solution. Can you see where I have went wrong here so that the right message is displayed depending if a radio button is selected or not?.

<head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title>Create a Session</title>
        <script type="text/javascript">

 function validation() {
                var errMsgContainerO = document.getElementById("radioAlert");
                var btnRad1O = document.getElementsByName("SessionNo");
                var isbtnRad1Checked = false;
                for(i=0; i < btnRad1O.length; i++){
                    if(btnRad1O[i].checked){
                        isbtnRad1Checked = true;
                        var btnNum = i;
                        i = btnRad1O.length;
                    }
                }
                if(!isbtnRad1Checked) {
                   errMsgContainerO.innerHTML = 'Click a radio button';
                } else {
                    errMsgContainerO.innerHTML = 'radio button '+ btnNum + ' was selected';
                }
                return false;  //for demo purposes
            }

  </script>
    </head>
    <body>

<form action="create_session.php" method="post" name="sessionform">
<table>
          <tr>
          <th>2: Number of Sessions :</th>
          <td class="sessionNo"><input type="radio" name="sessionNo" value="1" />1</td>
                  <td class="sessionNo"><input type="radio" name="sessionNo" value="2" />2</td>
                  <td class="sessionNo"><input type="radio" name="sessionNo" value="3" />3</td>
                  <td class="sessionNo"><input type="radio" name="sessionNo" value="4" />4</td>
                  <td class="sessionNo"><input type="radio" name="sessionNo" value="5" />5</td>
                  </tr>
                  </table>
                  <div id="radioAlert"></div>
</form>
</body>
  • 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-26T22:59:29+00:00Added an answer on May 26, 2026 at 10:59 pm

    You’re using “sessionNo” in the HTML, but “SessionNo” in the “getElementsByName()” call.

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

Sidebar

Related Questions

I have a slight problem with my dropdown function. What is suppose to happen
I have a slight problem with my application. What is suppose to happen is
Hey all, have a slight problem here. In CakePHP I have a controller that
I have a slight problem. Having recently migrated on Mac, I've been pulling my
I have a slight problem with a path: D:\\Music\\DJ Ti%C3%ABsto\\Tiesto\\Adagio For Strings (Spirit of
I have a slight problem... we made a change to our url structure the
I have a slight problem, I am trying to capture the input of two
am new here. i have a slight problem; PLease look at the following code
I've wrote this simple piece of code. And I have a slight problem with
hey everyone, here is the site SEE BELOW I have a slight jquery problem

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.