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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:58:45+00:00 2026-05-30T20:58:45+00:00

I really need an immediate with Javascript. I created a multiple choice question quiz

  • 0

I really need an immediate with Javascript.

I created a multiple choice question quiz in xhtml and tried to validate using Javascript. The problem is I’m able to display an alert message if any questions are unanswered, but I want to list out the unanswered question numbers in the same alert message. Please see the codes below.

<script type="text/javascript">
<!--
function validateRadio(radio) {
   var retval = false
   for ( var i = 0; i < radio.length; i++ ) {
      if ( radio[i].checked ) retval = true;
   }
   return retval;
}

// to make sure all questions are answered
function validateForm(theForm) // to make sure all questions are answered
{
   var retval = true;
   if ( !validateRadio(theForm.q1) ) retval = false;
   if ( !validateRadio(theForm.q2) ) retval = false;
   if ( !validateRadio(theForm.q3) ) retval = false;
   if ( !retval ) alert("Answer all of the questions");
   return retval;
}

// --></script>

<form name="quiz" action="result.php" method="post">

  <p>1. Choose the correct set of solution(s) by solving <img src="images/image002.png" width="93" height="17" alt=""/> equation?<br/>
    &nbsp;&nbsp;&nbsp;<input type="radio" name="q1" value="1"/>gh<br/>
    &nbsp;&nbsp;&nbsp;<input type="radio" name="q1" value="2"/>hk<br/>
    &nbsp;&nbsp;&nbsp;<input type="radio" name="q1" value="3"/>h<br/>
    &nbsp;&nbsp;&nbsp;<input type="radio" name="q1" value="4"/>ncb</p>

  <p>2. What is the value of <i>x</i> when 78x ?<br/>

    &nbsp;&nbsp;&nbsp;<input type="radio" name="q2" value="1"/>90<br/>
    &nbsp;&nbsp;&nbsp;<input type="radio" name="q2" value="2"/>656<br/>
    &nbsp;&nbsp;&nbsp;<input type="radio" name="q2" value="3"/>2<br/>
    &nbsp;&nbsp;&nbsp;<input type="radio" name="q2" value="4"/>5</p>

  <p>3. What is the value of 5x ?<br/>
    <input type="radio" name="q3" value="1"/>+3<br/>
    <input type="radio" name="q3" value="2"/>+6<br/>
    <input type="radio" name="q3" value="3"/>-3<br/>
    <input type="radio" name="q3" value="4"/>-6</p>


    <p><input type="submit" name="submit" value="Submit Now!" onclick="return validateForm(this.form)"/></p>
  • 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-30T20:58:46+00:00Added an answer on May 30, 2026 at 8:58 pm

    Do this:

    function validateForm(theForm) // to make sure all questions are answered
    {
       var retval = true;
       var unanswered = "";
       if ( !validateRadio(theForm.q1) ){retval = false;unanswered += "Question1\n";}
       if ( !validateRadio(theForm.q2) ){retval = false;unanswered += "Question2\n";}
       if ( !validateRadio(theForm.q3) ){retval = false;unanswered += "Question3\n";}
       if ( !retval ) alert("Answer all of the questions\nThe following were unanswered:\n" + unanswered);
       return retval;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really need advice on how to do the following. I have tried several
I really need an easy to use build tool which supports multiple languages with
I really need an answer to this question. I am working on a project
I need to be able to backup and restore my database using tsql. The
I have a problem with my app. I really need to kill it when
I really need your help in my issue very quickly and it's too close
I really need help with interfaces in general... Any resources that you guys would
I really need help on this one. I am having a simple login form
I really need some quick tips here. I've got this VBScript script which sends
I really need some help in Regular Expressions, i'm working on a function like

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.