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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:15:27+00:00 2026-06-10T22:15:27+00:00

I have this JavaScript function that highlight table TD’s when clicked on each individual

  • 0

I have this JavaScript function that highlight table TD’s when clicked on each individual TD

<script type="text/javascript">
    window.onload = function(){
    var all = document.getElementsByClassName("clicker");
    for (var i=0;i<all.length;i++) {
        all[i].onclick = inputClickHandler;       
    }
};

function inputClickHandler(e){
    e = e||window.event;
    var tdElm = e.target||e.srcElement;
    if(tdElm.style.backgroundColor == 'rgb(0, 153, 0)'){
        tdElm.style.backgroundColor = '#fff';
    } else {
        tdElm.style.backgroundColor = '#009900';
    }
}
    </script>

And I have a table say 8 by 8 and they are all square. Now above the table I have a form with a selection menu which looks like this.

<form id="filter">
<select id="highlights" name="highlights">
<option value="0"> Select... </option>
<option value="20"> 20 </option>
<option value="24"> 24 </option>
<option value="28"> 28 </option>
<option value="30"> 30 </option>
</select>

Basically what I want is for the user to select an option from the highlights form, so say I pick “24”, it then only allows me to highlight “24” squares in the table. If I change from “24” to “28” im then allowed to highlight “28” and no more than what is selected.
How would I do this?

  • 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-10T22:15:29+00:00Added an answer on June 10, 2026 at 10:15 pm

    Just do something like this:

    var max = 0, highlighted = 0
    document.getElementById('highlights').onchange = function () {
      max = this.value
    }
    ...
    function inputClickHandler(e){
      e = e||window.event;
      var tdElm = e.target||e.srcElement;
      if(tdElm.style.backgroundColor == 'rgb(0, 153, 0)'){
        highlighted--
        tdElm.style.backgroundColor = '#fff';
      } else if (highlighted != max) {
        highlighted++
        tdElm.style.backgroundColor = '#009900';
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I have the following jQuery code: <script type=text/javascript> $(document).ready(function() { var color = ['none',
I have this Javascript function that sends username and password to php file through
I have a JavaScript function that looks like this: function recalculateWhatIfCurrentRate(aEle, aChangedLabel, recordID, yearEndCurrentRate)
I have some third-party Javascript that has statements like this: FOO = function() {
Here is the situation. I have some javascript that looks like this: function onSubmit()
I have this JavaScript: var Type = function(name) { this.name = name; }; var
I have a problem with a javascript set of functions that I made. This
So I have this javascript function, it sends an ajax requests to fetch a
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();

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.