I’ve been trying to figure out a way to combine two JavaScript’s that are both used with table id. I don’t know much about coding, so have not been successful in my attempt. Don’t even know if this is possible or not, hopefully it is. Could somebody give me a hand?
Here are the two scripts:
[CODE]function tafla(uppl)
{
var ele = document.getElementById(uppl);
for(x = 0; x < ele.rows.length; x++)
{
ele.rows[x].style.height = “20px”
if (x%2 == 0)
{
ele.rows[x].style.backgroundColor = “#FDFBED”;
}
else
{
ele.rows[x].style.backgroundColor = “#F1EFE1”;
}
}
}
Script #2:
[CODE]function rowCount(countWord){
var table = document.getElementById(‘tbl’);
var rows = table.getElementsByTagName(‘tr’);
var avoid = [0];// Separate numbers by commas. e.g. [0,5]
function inArray(arr,fval){
for(var i = 0; i < arr.length; i++){
if(arr[i] == fval)
return true;
}
return false;
}
var cellCount = new Array();
for(var i=0;i<rows.length;i++){
var cells = rows[i].getElementsByTagName(‘td’);
for(var x=0;x<cells.length;x++){
var re = new RegExp(countWord,”gi”);
if(cellCount[x] == null){cellCount[x] = 0;}
if(re.exec(cells[x].innerHTML) != null){
cellCount[x] += 1;
}
}
}
var totalsRow = document.createElement(‘tr’);
for(var i=0;i<cellCount.length;i++){
var td = document.createElement(‘td’);
if (!inArray(avoid,i))
td.innerHTML = cellCount[i];
totalsRow.appendChild(td);
}
table.tBodies[0].appendChild(totalsRow);
}
window.onload = function(){
var lidtvo;
if( lidtvo=window.location.search.match(/[?&]lidtvo=(w+)/) )
var telja=lidtvo[1];
var divide=telja.replace(/(S)([A-Z])/g,’$1 $2′);
rowCount( divide ); //Pass the words which you want to count, seperate by pipe
}