Change the color of the values

0

I have <form> in which I return information I consulted in bd, until everything is working perfectly, however I would like to change the color of value according to the result. If value is "PENDING" it should be red and value is "OK" to be green.

Below is the code snippet.

<form>
  <label id="label">
     Status
  </label>
  <input id="input" type="text" class="form-control" name="status" 
     value="<?php echo " $status " ?>" 
     placeholder="" style="text-transform:uppercase" disabled="disabled">
</form>

Thank you.

    
asked by anonymous 02.01.2018 / 11:46

2 answers

0

PHP

<?php

if($status=="PENDENTE"){
    $cor="red";
}else{
    $cor="green";
}
?>

HTML Add in input style="background-color : <?php echo $cor ?>;"

<form>
  <label id="label">Status</label>
  <input id="input" type="text" class="form-control" style="background-color : <?php echo $cor ?>;" name="status" value="<?php echo " $status " ?>" placeholder="" style="text-transform:uppercase" disabled="disabled">
</form>
    
02.01.2018 / 12:04
0

Something like the example below should change the text color:

<style>
.pendente
{
    input, select, textarea{
        color: #ff0000;
    }
}
</style>

<form>
  <label id="label">Status</label>
  <input id="input" type="text" class="form-control <?php if(strtoupper($status) === 'PENDENTE') { echo 'pendente'; } ?>" name="status" value="<?php echo " $status " ?>" placeholder="" style="text-transform:uppercase" disabled="disabled">
</form>
    
02.01.2018 / 12:01