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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:37:57+00:00 2026-05-31T18:37:57+00:00

Im Making a question for a website and would like the the correct /

  • 0

Im Making a question for a website and would like the the correct / try again messages in the var reltext to be different colours ie green for correct and red for wrong and maybe a small png beside each.

any ideas ?

<form name = "Q1">
  <p>A local construction company has purchased 5 brand new diggers. Two of them have a telescopic jib. If a driver chooses a digger to use at random what is the probability it will have a telescopic jib?<br>

    0/5 
  <input name = "rad1" type = "radio" class="radio" onclick = "getAnswer('1a', '1')">
    1/5 
  <input name = "rad1" type = "radio" class="radio" onclick = "getAnswer('1b', '2')">
    2/5 
  <input name = "rad1" type = "radio" class="radio" onclick = "getAnswer('1c', '3')">
    3/5 
  <input name = "rad1" type = "radio" class="radio" onclick = "getAnswer('1d','4')">
  <br><br>
  </p>
<div id = "para"><div>
</form>

<script type = "text/javascript">
var reltext = [];
reltext[1] = "TRY AGAIN - 0/5 This would mean that there was no diggers with a telescopic jib." 
reltext[2] = "TRY AGAIN - 1/5 This would mean that there was only 1 digger with a telescopic jib"
reltext[3] = "CORRECT - 2/5 This would mean that there was 2 diggers with a telescopic jib" 
reltext[4] = "TRY AGAIN - 3/5 This would mean that there was 3 diggers with a telescopic jib."

function getAnswer(ans, rel) {
document.getElementById("para").innerHTML = reltext[rel];
if (ans == "1c") {alert ("Correct - Well done!")}
else {alert ("Incorrect - Try again")}
}

</script>
  • 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-31T18:37:58+00:00Added an answer on May 31, 2026 at 6:37 pm

    You could do this several ways.
    1. You could replace your reltext with the following:

    reltext[1] = "<div style='background-color:#dd0000;'>TRY AGAIN - 0/5 This would mean that there was no diggers with a telescopic jib.</div>"
    reltext[2] = "<div style='background-color:#dd0000;'>TRY AGAIN - 1/5 This would mean that there was only 1 digger with a telescopic jib</div>"
    reltext[3] = "<div style='background-color:#00dd00;'>CORRECT - 2/5 This would mean that there was 2 diggers with a telescopic jib</div>" 
    reltext[4] = "<div style='background-color:#dd0000;'>TRY AGAIN - 3/5 This would mean that there was 3 diggers with a telescopic jib.</div>"
    

    2. Or you could setup a style for the div with id="para". Something like:

    <style type="text/css">
    .classWrong { bakcground-color: #dd0000; }
    .classRight { background-color: #00dd00; }
    </style>
    

    and then in your script section change the function to set the style:

    function getAnswer(ans, rel) {
        document.getElementById("para").innerHTML = reltext[rel];
        if (ans == "1c") {
            document.getElementById("para").className = "classRight";}
            alert ("Correct - Well done!");
        else {
            document.getElementById("para").className = "classWrong";}
            alert ("Incorrect - Try again")}
        }
    

    3. As far as adding images to the response just add in an img element to your reltext. maybe like:

    reltext[1] = "<div style='background-color:#dd0000;'>TRY AGAIN - 0/5 This would mean that there was no diggers with a telescopic jib.<img src='images/Wrong.png' /></div>"
    
    reltext[3] = "<div style='background-color:#00dd00;'>CORRECT - 2/5 This would mean that there was 2 diggers with a telescopic jib<img src='images/Right.png' /></div>" 
    

    There are many other ways to do this but I thought I would just have a go at it.

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

Sidebar

Related Questions

Right now I'm making an extremely simple website- about 5 pages. Question is if
I have a question about tables in MySQL. I'm currently making a website where
Sorry for the newbie question! I'm making a small website that allows users to
I am developing a website for vacation home rentals, and I would like some
I'm making a website ( http://www.deayoga.ch/ ), and I'd like to make the menu
I'm sorry for maybe making such a basic question but in ASP.NET websites what
I apologize for making my first question not the hard-hitting code-related question I was
Making echo of a question around the web: Is the syntax for svn:ignore patterns
Simple RoR question...I am learning ROR and am making a simple voting app. The
I'm reviving this question, and making it more specific: Is there a .NET framework

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.