Change the color of values

Asked

Viewed 959 times

1

I own a <form> in which I return information I consulted in the comic book, so far everything is working perfectly, however I would like to change the color of the value according to the result. If the value is "PENDING" shall be red and if the value for "OK" to go green.

Below follows 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>

Thanks.

  • You want to change the color of the text inside the input?

  • Welcome Gabriel Barreto, take a tour https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-resposta/1079#1079

2 answers

0

Something like the example below should change the color of the text:

<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>

0


PHP

<?php

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

HTML Add to 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>
  • Sorry it took me so long to respond, but it helped a lot. Thank you Leo!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.