Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda