Hello
i am using chronoform v4
i am trying to add some javascript i made to delete rows in a table. i made it work on a regular html page, but i cannot integrate it with chronoform. could someone help me.
Here is the code that i copied to the On load JS
it basicaly 2 functions the first one changes the background of the rows and the second one delete the rows that have a value of zero in a cell. the code works fine, but not on chronoform.
thank you
i am using chronoform v4
i am trying to add some javascript i made to delete rows in a table. i made it work on a regular html page, but i cannot integrate it with chronoform. could someone help me.
Here is the code that i copied to the On load JS
it basicaly 2 functions the first one changes the background of the rows and the second one delete the rows that have a value of zero in a cell. the code works fine, but not on chronoform.
thank you
function altRows(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
if(i % 2 == 0){
rows[i].className = "evenrowcolor";
}else{
rows[i].className = "oddrowcolor";
}
}
}
}
function deleterow(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
for (var i = 0, row; row = table.rows[i]; i++) {
//iterate through rows
//rows would be accessed using the "row" variable assigned in the for loop
for (var j = 0, col; col = row.cells[j]; j++) {
//iterate through columns
//columns would be accessed using the "col" variable assigned in the for loop
if (table.rows[i].cells[2].innerHTML == '0'){
//table.rows[i].cells[2].innerHTML ='GOT IT' ;
//document.getElementById(id).deleteRow(1);
document.getElementById(id).deleteRow(i);
i=i-1
j=j-2
}
}
}
}
}
window.onload=function(){
deleterow('alternatecolor');
deleterow('alternatecolor2');
deleterow('alternatecolor3');
deleterow('alternatecolor4');
deleterow('alternatecolor5');
altRows('alternatecolor');
altRows('alternatecolor2');
altRows('alternatecolor3');
altRows('alternatecolor4');
altRows('alternatecolor5');
altRows('alternatecolor6');
}