[Zope] dynamic js lists

raharley at mailshack.com raharley at mailshack.com
Wed Dec 14 05:08:35 EST 2005


Hi all

Following up on my other post and having a read on quirksmode (thanks
Peter). I came up with the following which unsuprising doesnt want to work.
Could anyone point out any blindingly obvious code errors? I think it could
perhaps be something to do with the cells number, ie cell[0] etc.

Thanks
Rich

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
var rows;
onload = function(){
var heavyArr=[]; var softArr=[]; var goodtosoftArr=[]; goodArr=[]; var
goodtofirmArr=[]; var firmArr=[];
rows = document.getElementById('mytab').getElementsByTagName('tr');
for (var i=1;i<rows.length;i++){
var cells = rows[i].getElementsByTagName('td');
heavyArr[heavyArr.length]=[Number(cells[0].firstChild.data),'h'];
softArr[softArr.length]=[Number(cells[1].firstChild.data),'s'];
goodtosoftArr[goodtosoftArr.length]=[Number(cells[2].firstChild.data),'gts']
;
goodArr[goodArr.length]=[Number(cells[3].firstChild.data),'g'];
goodtofirmArr[goodtofirmArr.length]=[Number(cells[4].firstChild.data),'gtf']
;
firmArr[firmArr.length]=[Number(cells[5].firstChild.data),'f'];
}
arrMax=['','',sortA(heavyArr),sortA(softArr),sortA(goodtosoftArr)],sortA(goo
dArr)], sortA(goodtofirmArr)], sortA(firmArr)];
}
function sortA(a){
var b= a.sort(function (a, b) {return a[0] == b[0] ? 0 : (a[0] < b[0] ? -1
: 1)});
return b[b.length-1][0];
}
function highl(q){
for(var i=1;i<rows.length;i++){
var val = Number(rows[i].getElementsByTagName('td')[q].firstChild.data);
rows[i].style.backgroundColor=(val==arrMax[q])?'#66ccff':'';
}
}
</script>
</head>
<body>
<select id="sel" onchange="highl(this.selectedIndex+1)">
<option> -- select --</option>
<option value="heavy rating">heavy rating</option>
<option value="soft rating">soft rating</option>
<option value="goodtosoft rating">goodtosoft rating</option>
<option value="good rating">good rating</option>
<option value="goodtofirm rating">goodtofirm rating</option>
<option value="firm rating">firm rating</option>
</select>
<br>
<br>

TABLE GOES HERE WITH ID=mytab
</html> 

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .




More information about the Zope mailing list