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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:34:39+00:00 2026-05-31T17:34:39+00:00

having another problem with my javascript for my table. Basically, if you look at

  • 0

having another problem with my javascript for my table. Basically, if you look at the link I post, I have three cells with checkmarks and coloured red. When I click on the cell, the checkmark is removed and the cell changes colour. I want to make my reset button return the table to its initial state. However, this takes two clicks. You can test this out on the link here: http://cs1.ucc.ie/~od1/project_css/

Viewing the source there would be best but here is my javascript code that won’t allow it to work:

        function resetColour(objName){
            var arr = document.getElementsByName(objName);
            var arrLen = arr.length;

            for(var i = 0; i < arrLen; i++){
                if(arr[i].checked){
                    arr[i].parentNode.style.backgroundColor = "#F26C4F";
                }
                else{
                    arr[i].parentNode.style.backgroundColor = "#FAF4E3";
                }
            } 
        }

Is there any way I can make the form both reset and change colour with ONE click?

  • 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-31T17:34:40+00:00Added an answer on May 31, 2026 at 5:34 pm

    It is because it calls the function before the actual reset happen. The simplest (but the worst) way you can do is to wait for a few milliseconds to call your function.

    <input type="reset" name="reset" value="Reset" onclick="setTimeout('resetColour(\'free\')',200)" class="button">
    

    Edit
    Better option is to use normal button instead of reset button and call the function first and then the form.reset

    <input type="button" value="Reset Form" onClick="resetColour('free')';this.form.reset()" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an interesting but difficult problem with my JavaScript code. Basically, I'm trying
I am having another problem with my table and checkboxes. I ahve gotten my
I'm making another Pong clone using HTML5 canvas and JavaScript. The problem I'm having
The problem im having is that I have a table that when a user
I saw the other topic and I'm having another problem. The process is starting
As many of you may already know I have been having issues with another
Having dealt with yet another stupid eclipse problem, I want to try to get
I've been having a problem with the javascript innerHTML function when using forms. I've
I've been having a problem using the javascript API of the RadComboBox from Telerik.
I'm trying to use inheritance in JavaScript here, and I found problem having array

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.