Forum Moderators: open
<script language="javascript" type="text/javascript">
function writeLayer(layerID,txt){
if(document.getElementById){
document.getElementById(layerID).innerHTML=txt;
}else if(document.all){
document.all[layerID].innerHTML=txt;
}else if(document.layers){
with(document.layers[layerID].document){
open();
write(txt);
close();
}
}
}
function updateRating(similarityLevel) {
http.open("GET", url, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
var finalRating = 0.0;
var count = 0;
for (var i in reviews) {
if (reviews[i][1] >= similarityLevel) {
finalRating += parseFloat(reviews[i][2]);
count++;
}
}
finalRating /= count;
writeLayer("overallRating", finalRating);
}
</script>
(I've left out a few functions to shorten the post.)
When I call writeLayer with a body onload the <div> get updated.
<body onload="javascript:writeLayer('overallRating','40')">
But when I call updateRating, which then calls writeLayer, from the onload the <div> never is updated.
<body onload="javascript:updateRating(40)">
I know the function is being run because I can add an alert which is displayed.
Anyone know why the <div> wouldn't be updated?
(sorry about the formatting, I can't get spaces or tabs to work)