I dynamically generated a php page with a single text element form and a table of data. Each row of the table has a barcode as the name (). As I scan each barcode in the form, I’d like to change the row color using jquery.
Php page simplified:
<form id="checkinProcess" class="mainForm" method="post" action="">
<label>Barcode:</label>
<input type="text" class="required" name="barocde" id="processBarcode"/>
<input type="submit" value="submit" class="blueBtn" />
</form>
<table class="display" id="barcodeTable">
<thead>
<tr>
<th>Barcode</th>
<th>Amount</th>
<th>Code</th>
</tr>
</thead>
<tbody>
<tr id="B12345" class="odd">
<td>B12345</td>
<td>20.3</td>
<td>External</td>
</tr>
<tr id="B23456" class="even">
<td>B23456</td>
<td>19.6</td>
<td>Internal</td>
</tr>
<tr id="B34567" class="odd">
<td>B34567</td>
<td>22.0</td>
<td>Internal</td>
</tr>
</tbody>
</table>
Table Css:
tr.odd { background-color: #F9F9F9; }
tr.even { background-color: white; }
tr.curChecked {background-color: #33CC33; }
jQuery attempt:
$('#checkinProcess').submit(function(e){
e.preventDefault();
$("tr.processBarcode").removeClass("odd" "even").addClass("curChecked");
});
How do I pass the barcode scanned in the form to my JQuery to identify which tr tag’s class I want changed? Can I even do that?
Thanks
Worked.