-1

i got the currenttime value and if the currenttime is equal to the row time of the workday planner,it should display a color. if current time is more than the row time ,the text area should display a different color. if current time is less than the row time ,then text area should display a different color.

<div id="9" class="row">
        <div class="col-2 col-md-1 hour text-center py-3">9AM</div>
        <textarea class="col-8 col-md-10 description" rows="3" id="txtarea"> </textarea>
        <button class="btn saveBtn col-2 col-md-1" aria-label="save">
          <i class="fas fa-save" aria-hidden="true"></i>
        </button>
      </div>
      <div id="10" class="row">
        <div class="col-2 col-md-1 hour text-center py-3">10AM</div>
        <textarea class="col-8 col-md-10 description" rows="3" id="txtarea"> </textarea>
        <button class="btn saveBtn col-2 col-md-1" aria-label="save">
          <i class="fas fa-save" aria-hidden="true"></i>
        </button>
      </div>

var rowlist =document.querySelectorAll(".row");


var rowlistarr= Array.from(rowlist);
var index=0;


function timeblock()

{
  for(index=0;index<rowlistarr.length;index++){

    if(time =rowlistarr){
      var areacolor=document.getElementById("#textarea").innerHTML;

     areacolor.style.color="Yellow";
    }
else if(time<rowlistarr)
{
  var areacolor=document.getElementById("#textarea").innerHTML;

     areacolor.style.color="Yellow";

}
else if(time>rowlistarr)
{

  var areacolor=document.getElementById("#textarea").innerHTML;

  areacolor.style.color="Yellow";

}

    //console.log(rowlist[index]);
  }
}

DDVino
  • 1
  • 1
    There is no element with the ID `#textarea`. Even if we were to excuse your confusion of [`getElementById`](//developer.mozilla.org/en/docs/Web/API/Document/getElementById) with [`querySelector`](//developer.mozilla.org/en/docs/Web/API/Document/querySelector), there still isn’t even an element with the ID `textarea`. Duplicate IDs are invalid. How do you expect this to work? Use the [browser console (dev tools)](//webmasters.stackexchange.com/q/8525) (hit `F12`), read any errors. [Validate your HTML](//html5.validator.nu). – Sebastian Simon Nov 24 '22 at 03:43
  • 1
    `if(time = rowlistarr)` isn’t a comparison. Please see [What is the difference between the `=` and `==` operators and what is `===`?](/q/11871616/4642212). Use linters like [ESLint](//eslint.org/play) or [JSHint](//jshint.com) to find problems with your code immediately. Learn about [how to debug small programs](//ericlippert.com/2014/03/05/how-to-debug-small-programs). Try using your browser’s [debug capabilities](//ali-dev.medium.com/how-to-easily-debug-in-javascript-5bac70f94f1a). See [What is a debugger and how can it help me diagnose problems?](/q/25385173/4642212). – Sebastian Simon Nov 24 '22 at 03:46
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 24 '22 at 04:27
  • Too many errors to provide a useful answer, as included above, but also: `=` isn't `==`, duplicate IDs, `textarea`!=`txtarea`, `.innerHTML.style`, no definition of `time`, then, if all of these were fixed - your `==`,`>`, and `<` *all* set to yellow. Start by checking your browser console for errors (F12). – freedomn-m Nov 24 '22 at 05:46

1 Answers1

0

Remove the innerHTML property at the end of your getElementById() call.

instead of

var areacolor=document.getElementById("#textarea").innerHTML;

use

var areacolor=document.getElementById("#textarea")
Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
Dipo Ahmed
  • 327
  • 2
  • 6