Page 1 of 1

Can I make this highlight TR and not just TD?

Posted: Thu May 24, 2012 10:12 am
by simonmlewis

Code: Select all

<script type="text/javascript">
function check(it) {
  tr = it.parentElement.parentElement;
  tr.style.backgroundColor = (it.checked) ? "gold" : "white";
}
</script>
<form onsubmit="return false">
<table border width=100%>
<tr><td><input type="checkbox" onclick="check(this)"></td><td>testing!</td><td>testing!</td><td>testing!</td><td>testing!</td></tr>
</table>
When I click the box, it highlights only the TD cell it's in, not the whole row.

Any ideas why?

Re: Can I make this highlight TR and not just TD?

Posted: Thu May 24, 2012 10:21 am
by Celauran
Highlights the whole row for me...

Re: Can I make this highlight TR and not just TD?

Posted: Thu May 24, 2012 10:28 am
by simonmlewis
strange, does for me when raw...... will have to check my code.

Re: Can I make this highlight TR and not just TD?

Posted: Thu May 24, 2012 10:31 am
by simonmlewis

Code: Select all

echo "<tr><td align='center'><label><font style='font-size: 10px'>TICK TO<br/>CHOOSE</font><input type='checkbox' name='X1include' value='yes' onclick=\"check(this)\"></label></td><td><img src='/images/productphotos/small/$rowac->photoprimary' /> </td><td><div class='sectionhead' style='margin-top: 0px'>$rowac->title</div><b>Choose color of Grout:</b>
      <select name='X1itemcode'>";
      if ($rowac->size1 != '') { echo "<option value='$rowac->romancode1'>$rowac->size1</option>";}
      if ($rowac->size2 != '') { echo "<option value='$rowac->romancode2'>$rowac->size2</option>";}
      if ($rowac->size3 != '') { echo "<option value='$rowac->romancode3'>$rowac->size3</option>";}
      if ($rowac->size4 != '') { echo "<option value='$rowac->romancode4'>$rowac->size4</option>";}
      echo "</select><br/><b>Packs needed:</b> <input type='text' name='X1quantity' ";
      $amount = $row->amountgrout * $quantity; 
      echo "value='$amount' $row->amountgrout' size='5'> x &pound; $rowac->price1</td></tr>";
This is my row. The code at the top is the same as previously entered.
It will ONLY highlight the TD.

Re: Can I make this highlight TR and not just TD?

Posted: Thu May 24, 2012 10:38 am
by simonmlewis
Damn - it's the <label>.
I need that to make it easier to tick, BUT, take it off and this script works.