sayedsohail Posted March 4, 2007 Share Posted March 4, 2007 Hi everyone, I got a small problem, i am displaying data in a html table with five rows of five columns each, the first row is a title row with blue background, and the 2nd row onwards is the data rows with a radio button. When a user click first row, nothing should happend, but when the user clicks the radio button or any column of the row, I wish to select the radio value (clicked) and set the background color to silver for the entire row of five columns. Here is my javascript code which is working fine, except it removed the first row style background color, which I don't wish to remove. any suggestions would be highly appreciated. var trs = document.getElementsByTagName('tr'); function color(obj) { for(var i=0; i < trs.length; i++) { var cells = trs[i].getElementsByTagName('td'); for(var p=0; p < cells.length; p++) { cells[p].style.backgroundColor='white'; } } currentCells = obj.getElementsByTagName('td'); for(var n=0;n<currentCells.length;n++) { currentCells[n].style.backgroundColor = 'silver'; } } Link to comment https://forums.phpfreaks.com/topic/41087-change-background-color-in-table-from-2nd-row-onwards/ Share on other sites More sharing options...
pocobueno1388 Posted March 4, 2007 Share Posted March 4, 2007 Ummm...this is the PHP forum, you should post this in the javascript forum. Link to comment https://forums.phpfreaks.com/topic/41087-change-background-color-in-table-from-2nd-row-onwards/#findComment-198953 Share on other sites More sharing options...
sayedsohail Posted March 4, 2007 Author Share Posted March 4, 2007 I apologize, but please can someone help. Link to comment https://forums.phpfreaks.com/topic/41087-change-background-color-in-table-from-2nd-row-onwards/#findComment-198955 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.