Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
change radar color on condition using existing js file variable

I have a radar_box div which is color #7eb6ff, i want to change the color to red if the jsonstr value in external javascript file is above 100. my code is so far doing nothing:

html:

    <script type="text/javascript" src="../declare.js"></script>

        <section id="alert">
        <h1>alert</h1><br><br>
        <div class="radar_box_area">
            <div class="radar_box" id="radar_box">
                <div class="radar"></div>
            </div>
        </div>
        <script>
            var mmm=document.getElementById("radar_box");
            function cond(){
                if(jsonstr > 100){
                    mmm.style.backgroundColor("red");
            }}

       </script>
    </section>

my declare.js file:

var jsonstr = ["131.05\r\n"] 

if the solution is to write my condition in js file, i can't do it because declare.js is created when i run python code. so the whole file is rewritten.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

in cond function use this snippet. what we done here is just replace any spaces, convert return str to number by using + sign and then compare with value.

var jsonstr = ["131.05\r\n"];
const check = +jsonstr[0].replace(/(\r\n|\n|\r)/gm, '')

if (check > 100) {
  console.log('in', check)
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!