I have table in the jsp which is dynamically populated. I used same id for all the table rows.
In the javascript I want to retreive all the table row elements whose id is "resultRow". and getElementsByName("resultRow") in js gives empty htmlcollection in IE10
Is there any other way to get the tablerows of matched id
Any help is greatly appreciated
`here is my code snippet
In JSP:
<table id="subSecondTable" cellpadding="0" cellspacing="0">
<c:set var="loopCount" value="0" />
<c:forEach var="vinList" items="${requestScope.vehicleDetailsPO}">
<tr id="resultRow" height="10" class="handCursor"
onclick="rowColorChange('<c:out value="${loopCount}"/>','<c:out value="${vinList.vin}"/>');">
In js:
function rowColorChange(rowNumber,vin){
var rows=document.getElementsByName("resultRow");
var columns;
rowHighlighted=rowNumber;
for(i=0;i<rows.length;i++){
if (i==rowNumber){
rows[rowNumber].style.backgroundColor="blue";
//change the text color for the highlighted row
columns = rows[rowNumber].cells
for(j=0;j<columns.length;j++){
columns[j].style.color = "white";
}
//change the text color for the highlighted row
var previousRowint = parseInt(previousRow);
if (previousRow != rowNumber)
{
columns = rows[previousRowint].cells
for(j=0;j<columns.length;j++){
columns[j].style.color = "black";
}
}
previousRow=rowNumber;
if(vin==''){
vin = rows[parseInt(rowHighlighted)].cells[3].innerText;
}
document.getElementById("txtCopyVin").value=vin;
document.getElementById("txtCopyVin").select();
}else{
rows[i].style.backgroundColor="white";
}
}
if(window.event!=null){
rows[rowNumber].cells(window.event.srcElement.cellIndex).focus();
}
}`