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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:10:09+00:00 2026-06-01T04:10:09+00:00

My score increment is not working. Two questions. Will it automatically update? Or is

  • 0

My score increment is not working. Two questions.

Will it automatically update?

Or is my code wrong?

HTML Page

<script>document.write("Score: " + score);</script>

<table class="widthOneHundredPercent">
<tr>
 <td class="tableCellFloat columnOne" valign="top">
  <div class="question"><b>Question 1:</b> Who is the youngest in B Media?</div>
 <td class="tableCellFloat columnTwo" valign="top">   
     <div class="answers">
            <ol>
                <li>
                    <input type="radio" name="q1" id="q1-a" onclick="unhide(this); scoreIncrement()"/>John
                </li>
                <li>
                    <input type="radio" name="q1" id="q1-b" onclick="unhide(this)"/>Paula
                </li>
                <li>
                    <input type="radio" name="q1" id="q1-c" onclick="unhide(this)"/>Henal
                </li>
                <li>
                    <input type="radio" name="q1" id="q1-d" onclick="unhide(this)"/>Malc
                </li>
            </ol>
        </div>
 </td>
 </td>
</tr>
<tr>
 <td colspan="2" valign="top">
    <div id="answerq1a" class="hidden">
 <p>Your answer is correct, John is 20.</p>
    </div>
 </td>
</tr>
<tr>
 <td colspan="2" valign="top">
    <div id="answerq1b" class="hidden">
 <p>Your answer is incorrect, Paula is 31.</p>
    </div>
 </td>
</tr>
<tr>
 <td colspan="2" valign="top">
    <div id="answerq1c" class="hidden">
 <p>Your answer is incorrect, Henal is 21.</p>
    </div>
 </td>
</tr>
<tr>
 <td colspan="2" valign="top">
    <div id="answerq1d" class="hidden">
 <p>Your answer is incorrect, Malc is 33.</p>
    </div>
 </td>
</tr>
</table>​

​Javascript

var currentShown = "";

function unhide(rad) {
    var id = "answer" + rad.id.replace("-", "");
    var answer = document.getElementById(id);
    if (answer) {
        var current = document.getElementById(currentShown);
        if (current) current.className = "hidden";
        currentShown = id;
        answer.className = "unhidden";
    }
}

var score = 0;

function scoreIncrement() {

    score++;
}​

Such simple code, yet it wont work, obviously I’ve written it wrong but I cannot see what is wrong?

  • 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-01T04:10:10+00:00Added an answer on June 1, 2026 at 4:10 am

    You’re document.write’ing the score out, but never updating the call so even though your score increments it’s not being updated on the page…

    Update your HTML with something like:

    <!-- <script>document.write("Score: " + score);</script> -->
    <span id="score"></span>
    

    and your javascript with something like

    function scoreIncrement() {
        score++;
        document.getElementById("score").innerText="Score: " + score; 
    }​
    

    That should do it. The most elegant solution, maybe not, but it does work.

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

Sidebar

Related Questions

I am working on a project in CakePHP 1.3 which will store a collection
I will accept an alternative to sprintf only if you explain why it's not
I have two mysql tables: /* Table users */ CREATE TABLE IF NOT EXISTS
I'd like to increment (or decrement) a score field in an Elixir entity: class
I have the following table: CREATE TABLE `score` ( `score_id` int(10) unsigned NOT NULL
How can I increment an integer value outside the scope of a parallel.foreach loop?
class Score { var $score; var $name; var $dept; var $date; function Score($score, $name,
I have a high score database for a game that tracks every play in
I have a score i need to calculate for multiple items for multiple users.
How would you model a simple musical score for a single instrument written in

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.