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'; } } Quote Link to comment Share on other sites More sharing options...
LazyJones Posted March 4, 2007 Share Posted March 4, 2007 how about this: ... for(var i=1; i < trs.length; i++) ... Quote Link to comment Share on other sites More sharing options...
sayedsohail Posted March 4, 2007 Author Share Posted March 4, 2007 thanks. Quote Link to comment Share on other sites More sharing options...
sayedsohail Posted March 4, 2007 Author Share Posted March 4, 2007 within the click row, i have got a radio button, which i wish to set as checked when users click on any ofthe table data row and column for lazy users. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.