posted 19 years ago
Hi
I would like to know how to I include colors to the alternate rows....
I did it with using style, but I am not getting the color.
Also, I would like to know how to include header for the table...
--------------------------------------------------------------------------
style
.odd{background-color: white;}
.even{background-color: gray;}
style
script type="text/javascript"
function alternate(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
//manipulate rows
if(i % 2 == 0){
rows[i].className = "even";
}else{
rows[i].className = "odd";
}
}
}
}
function SendInfo(){
var txtVal = document.formPop.popupoldPart.value;
var txtVal1 = document.formPop.popupnewPart.value;
var tbl = window.opener.document.getElementById('tblSample1');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode1 = window.opener.document.createElement('input');
textNode1.setAttribute('type', 'image');
textNode1.setAttribute('name', 'Edit' + iteration);
textNode1.setAttribute('id', 'Edit' + iteration);
textNode1.setAttribute('width', '20');
textNode1.setAttribute('height', '20');
textNode1.setAttribute('src', 'editRow.gif');
cellLeft.appendChild(textNode1);
var cellLeft = row.insertCell(1);
var textNode1 = window.opener.document.createElement('input');
textNode1.setAttribute('type', 'image');
textNode1.setAttribute('name', 'Edit' + iteration);
textNode1.setAttribute('id', 'Edit' + iteration);
textNode1.setAttribute('width', '20');
textNode1.setAttribute('height', '20');
textNode1.setAttribute('src', 'deleteRow.gif');
cellLeft.appendChild(textNode1);
var cellMiddle = row.insertCell(2);
var textNode = window.opener.document.createElement('input');
textNode.setAttribute('type', 'text');
textNode.setAttribute('name', 'txtRow' + iteration);
textNode.setAttribute('id', 'txtRow' + iteration);
textNode.setAttribute('size', '40');
textNode.setAttribute('value', txtVal);
cellMiddle.appendChild(textNode);
// right cell
var cellRight = row.insertCell(3);
var el = window.opener.document.createElement('input');
el.setAttribute('type', 'text');
el.setAttribute('name', 'txtRow' + iteration);
el.setAttribute('id', 'txtRow' + iteration);
el.setAttribute('size', '40');
el.setAttribute('value', txtVal1);
cellRight.appendChild(el);
// window.opener.document.form1.text1.value = txtVal;
//window.opener.document.form1.text2.value = txtVal1;
window.close();
}
form name="formPop"
Part Number Old: input type="text" name="popupoldPart" Part Number New:input type="text" name="popupnewPart"
input type="button" name="button" value="OK"
click="SendInfo()"
---------------------------------------------------------------------------
Thanks in Advance.