Home > Software engineering >  highlight row based on cell value - Perl Script
highlight row based on cell value - Perl Script

Time:04-28

I'm having trouble highlighting a row when column F displays a value of F. I know I can accomplish this by CSS/JS but keep running into a brick wall. I'm very new to coding and would like some help if possible.

Goal: Need to highlight entire row yellow when Column F displays a value of F.

Thank you in advance!!!

    <div class='row'>
                <div class='col-lg-12 col-sm-12'>
                    <div class='panel panel-primary'>
                        <div class='panel-heading'>
                            <h3 class='panel-title'><i class='fa fa-bar-chart-o'></i>Priority Lots</h3>
                        </div>
                        
                        <table class='table'>
                            <thead>

                            <tr>
                                    <th>LOT</th>
                                    <th>LPT</th>
                                    
                                    <th>OPN</th>
                                    <th>DEVICE</th>
                                    <th>QTY</th>
                                    <th>DTTM</th>

                                    <th>I</th>
                                    <th>H</th>
                                    <th>F</th>
                                    <th>P</th>

                                    <th>S</th>
                                    <th>LOCATION</th>
                                    <th>STATUS</th>
                                    <th>EQUIP</th>
                                </tr>
                            </thead>
                            
                    </div>";
                    
                    
$sqlstr="select l.lot, l.lpt, lc.opn, ls.device, l.cur_qty as qty, 
round((sysdate - l.last_act_dttm)*24,1) as dttm, 
l.isc as i, l.hold as h, l.ftr_hold as f, ls.priority as p, 
ls.swr as s, ls.lot_code3 as location, 
decode (lc.lot_status,'P',' Processing ') as status, lc.equip
from lot l, lot_str ls, lot_cur_opn lc, lpt_grp_lpt_lst lg  
where l.facility = 'DP1DM5' and lc.facility = l.facility 
and ls.facility = l.facility and lg.lpt_grp_facility = 'DP1DM5'
and l.lot = ls.lot and l.lot = lc.lot 
and ls.latest = 'Y' and ls.priority != 'N' 
and ls.priority IN ('0','1','2','3')
and l.lpt < 'TRM' and ls.latest = 'Y' and l.lpt = lg.lpt
and lg.lpt_grp_type = 'G' and lg.lpt_grp = '3005'
order by p, lpt

";
$sth = $dbh->prepare($sqlstr);
$sth->execute();
$sth->bind_columns(undef, \$LOT, \$LPT, \$OPN, \$DEVICE, \$QTY, \$DTTM, \$I, \$H, \$F, \$P, \$S, \$LOCATION, \$STATUS, \$EQUIP);

while($sth->fetch()) {
    

   print "
                    
        <tbody>
                            
        <tr class='row100 body'>
                                    <td class='cell100 column4'>$LOT</td>
                                    <td class='cell100 column4'>$LPT</td>
                                    <td class='cell100 column4'>$OPN</td>
                                    <td class='cell100 column4'>$DEVICE</td>
                                    <td class='cell100 column4'>$QTY</td>
                                    <td class='cell100 column4'>$DTTM</td>
                                    <td class='cell100 column4'>$I</td>
                                    <td class='cell100 column4'>$H</td>
                                    <td class='cell100 column4'>$F</td>
                                    <td class='cell100 column4'>$P</td>
                                    <td class='cell100 column4'>$S</td>
                                    <td class='cell100 column4'>$LOCATION</td>
                                    <td class='cell100 column4'>$STATUS</td>
                                    <td class='cell100 column4'>$EQUIP</td>
                                    
                                  
                                    

      


   </tr>";

   
}

                  

                    print "</tbody>
                        </table>
                        
                    </div>
                    <BR>
                    <BR>
                    </div>

Here is a screenshot of the column F:

enter image description here

CodePudding user response:

On creating simple stub HTML page this worked to highlight the row in yellow or not.

  my ($LOT, $LPT, $OPN, $DEVICE, $QTY, $DTTM, $I, $H, $F, $P, $S, $LOCATION, $STATUS, $EQUIP) = ('LOT', 'LPT', 'OPN', 'DEVICE', 'QTY', 'DTTM', 'I', 'H', 'F', 'P', 'S', 'LOCATION', 'STATUS', 'EQUIP');
  print "<html><body><table>\n";

# while($sth->fetch()) {
my $highlight = $F eq 'F' ? ' BGCOLOR="#FFFF00"' : '';
print "
        <tbody>
        <tr$highlight class='row100 body'>
                                    <td class='cell100 column4'>$LOT</td>
                                    <td class='cell100 column4'>$LPT</td>
                                    <td class='cell100 column4'>$OPN</td>
                                    <td class='cell100 column4'>$DEVICE</td>
                                    <td class='cell100 column4'>$QTY</td>
                                    <td class='cell100 column4'>$DTTM</td>
                                    <td class='cell100 column4'>$I</td>
                                    <td class='cell100 column4'>$H</td>
                                    <td class='cell100 column4'>$F</td>
                                    <td class='cell100 column4'>$P</td>
                                    <td class='cell100 column4'>$S</td>
                                    <td class='cell100 column4'>$LOCATION</td>
                                    <td class='cell100 column4'>$STATUS</td>
                                    <td class='cell100 column4'>$EQUIP</td>
   </tr>";
}
print "</tbody></table>\n";
#
  print "</body></html>\n";
  • Related