javascript - Check the dropdowns and change cell colors dynamically -


i have web table displaying sql server database table using php pdo. table created , displayed on index.php file. have form in edit.php users can update table. of fields in edit.php have dropdowns. example, 1 field has dropdown options q1,q2,q3,and q4. if initial value q1 or user updates q1, want make background color of cell in table green, if q2=>yellow, q3=>red. can please me this? have index.php , edit.php shown below:

index.php

<?php require_once('include/database.php'); ?>  <!doctype html> <html> <head>     </head> <body> <tr><th>q rating</th></tr> <tr><th>action</th></tr>  <?php         $stmt = $conn->prepare("select * matrix order objectid asc");         $stmt ->execute();         $result = $stmt->fetchall();         foreach($result $row) {          ?>      <tr>     <td><?=$row['q_rating'];?></td>     <td><a href="edit.php?id=<?=$row['objectid'];?>">edit </a>  </td> 

edit.php

   <form action="" method="post">      <tr>                 <td>atfp</td>                 <td><label>                         <select name="txt_qrating" class="textfields"           id="q_rating">                             <option id="0">select one</option>                             <option id="1"> q1</option>                             <option id="2">q2</option>                             <option id="3">q3</option>                             <option id="4">q4</option>                          </select>                      </label>                 </td>             </tr>              <tr>                 <td><label>                         <input type="hidden" name="txt_id" value="<?= $object_id; ?>">                     </label>                 </td>                 <td><label><input type="submit" name="btn_submit" value="submit">                     </label>                 </td>             </tr> 

simply add css style proper classes:

.green { color: green;} .red { color: red;} 

.. add inline conditionals like:

<table> <tbody><tr> <td class="<?php echo ("quatity1" === $myvar ? 'red' : 'green'; ?>">tdvaluehere</td> </tr></tbody></table> 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -