|
<html>
<title>
malakas
</title>
<body style="width:800px;height:600px;border:1px black solid;">
<script type="text/javascript">
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument(""," ",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("note4.xml");
var x=xmlDoc.getElementsByTagName("item");
for (i=0;i<13;i++)
{
title = x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
description = x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue;
score = x[i].getElementsByTagName("score")[0].childNodes[0].nodeValue;
document.write('<div id="mydiv" style="background:red">');
document.write(transform(score,"mydiv"));
document.write("<h3>"+title+"</h3>");
document.write("<br/>");
document.write(description);
document.write("<br/>");
document.write("Score : ");
document.write(score);
document.write("<br/>");
document.write("</div>");
}
}
function transform(scr,divname)
{
var div = document.getElementById(divname);
if(scr>0.7) {
div.style.height = 0.3*document.body.offsetHeight +'px';
div.style.width = 0.2*document.body.offsetWidth + 'px';
}
}
</script>
</body>
</html>
My problem is that my code changes the height/width of the first element only(with score>0.7) all the other elements-divs have the same height/width although some of them have score>0.7.
Why is that?
helppppppp pleaseeeeee!!!!!!!
Last edited by spirtokouto; 01-06-2009 at 05:24 PM..
|