Page 1 of 1
how to hilite a row?
Posted: Wed Jan 04, 2006 12:42 am
by saumya
i have a table and in the beginnning column I have radio buttons each for a row.Now my problem is,If somebody clicks on a particular radio button then the whole row should get hilited.Is it possible?? Can you guide me, please.
Posted: Wed Jan 04, 2006 4:49 am
by djot
-
With javascript you may check whether a radio button is checked. On that event you may alter the background of the row also (by javascript only).
djot
-
Posted: Wed Jan 04, 2006 6:31 am
by saumya
but how to know which row??
is there a variable or property of the table specifying the row identity??
Posted: Wed Jan 04, 2006 9:54 am
by pickle
I'm not certain, but I believe you can also put an onclick event handler on the row itself. In that handler, use 'this.style.backgroundColor' to change the colour. You'll need to use fancier javascript to change it back to unhighlighted as well.
Posted: Wed Jan 04, 2006 10:17 am
by Burrito
Do something like this you could...
Code: Select all
<table>
<tr onClick="(this.style.backgroundColor == '#ff0000' ? this.style.backgroundColor = '#ffffff' : this.style.backgroundColor = '#ff0000')">
<td>
<input type="radio" name="blah" value="blah">
</td>
<td>
Blah
</td>
</tr>
</table>
although change the row color back it will not when selecting a different radio button (on a different row) you are.
Posted: Thu Jan 05, 2006 12:06 am
by saumya
wow, thatworked man.But how to get back the others bg color to normal??

(
Posted: Thu Jan 05, 2006 9:35 am
by Burrito
for that, you'd have to loop over all of the other rows and turn their background color back to nothing or some other default color. Should be pretty easy to do, just loop the rows first, then change the current row's color to whatever you want.