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

254
Vistas
flash de color negativo, quiero cambiar el color del valor negativo de negro a rojo y positivo en verde

tengo este formato de tabla de precios y quiero mostrar en la tabla con flash color ¿alguna ayuda con esto qué hacer? decodificar codificar buscar? tengo este formato de tabla de precios y quiero mostrar en la tabla con flash color ¿alguna ayuda con esto qué hacer? decodificar codificar buscar?

 <?php $bidRateUNI = 10 ; $UNIUSDBUY = 22; $UNIUSDSELL = 33; $BUY1UNI = $bidRateUNI - $UNIUSDBUY; $BUY2UNI = $bidRateUNI - $UNIUSDSELL; $SELL1UNI = $UNIUSDBUY - $bidRateUNI; $SELL2UNI = $UNIUSDSELL - $bidRateUNI; ?> <html> <body> <title>untitled</title> <style> .negative { color : red; } .positive { color : green; } </style> <?php echo '<table> <tr> <td class="plusmin">$SELL2UNI</td> <td class="plusmin">$SELL1UNI</td> <td>$9,500</td> <td class="plusmin">$BUY2UNI</td> <td class="plusmin">$BUY1UNI</td> </tr> <tr> <td class="plusmin">$53.12</td> <td class="plusmin">+2.5%</td> <td>£110,000</td> <td class="plusmin">$10,000</td> <td class="plusmin">+15.57%</td> </tr> </table>'; ?> <script> function MakePosNeg() { var TDs = document.querySelectorAll('.plusmin'); for (var i = 0; i < TDs.length; i++) { var temp = TDs[i]; if (temp.firstChild.nodeValue.indexOf('-') == 0) {temp.className = "negative";} else {temp.className = "positive";} } } onload = MakePosNeg() </script> </body> </html> **; help with some good info** ;help with some good info ';help with some good info **; help with some good info** ;help with some good info ';help with some good info
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Tu pregunta no está clara. ¿Qué quieres que sea de color? ¿La columna? ¿La fila? ¿La célula?

¿Estás coloreando la salida de PHP?

Sin embargo, el método más simple sería usar el operador ternario en PHP en lugar de usar javascript. Un operador ternario es esencialmente una declaración if/else abreviada. Aquí hay un ejemplo (basado en el supuesto de que desea colorear la fuente del código PHP).

echo "<td style='color: " . $BUY1UNI < 0 ? 'red' : 'green' . "'>" . number_format($BUY1UNI, 3) . "</td>";

about 4 years ago · Juan Pablo Isaza Denunciar

0

Te has equivocado con tu código. no necesita javascript para eso como @jeff Vdovjak y también ha abierto etiquetas php innecesariamente, lo que genera confusión. Supongo que el siguiente código te ayudará.

 <?php $bidRateUNI = 10 ; $UNIUSDBUY = 22; $UNIUSDSELL = 33; $BUY1UNI = $bidRateUNI - $UNIUSDBUY; $BUY2UNI = $bidRateUNI - $UNIUSDSELL; $SELL1UNI = $UNIUSDBUY - $bidRateUNI; $SELL2UNI = $UNIUSDSELL - $bidRateUNI; ?> <html> <body> <title>untitled</title> <table> <td class="plusmin" style='color:<?php if($SELL2UNI<0){echo"red";}else{ echo"green";}?>'><?php echo $SELL2UNI?></td> <td class="plusmin" style='color:<?php if($SELL1UNI<0){echo"red";}else{ echo"green";}?>'><?php echo $SELL1UNI?></td> <td>$9,500</td> <td class="plusmin" style='color:<?php if($BUY2UNI<0){echo"red";}else{ echo"green";}?>'><?php echo $BUY2UNI?></td> <td class="plusmin" style='color:<?php if($BUY1UNI<0){echo"red";}else{ echo"green";}?>'><?php echo $BUY1UNI?></td> </tr> <tr> <td class="plusmin">$53.12</td> <td class="plusmin">+2.5%</td> <td>£110,000</td> <td class="plusmin">$10,000</td> <td class="plusmin">+15.57%</td> </tr> </table>
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