<script language="javascript">
var min=18,max=30
function InitTemp()
{
var temp=document.getElementById("temperature");
CreateImgTemp(temp.value);
}
function ChgTemp(diff)
{
var temp=document.getElementById("temperature");
var val=eval(temp.value);
if (diff<0&&val>min)
val--;
if (diff>0&&val<max)
val++;
CreateImgTemp(val.toString());
}
function CreateImgTemp(val)
{
var str="";
for (var i=0;i<val.length;i++)
{
str+='<img src="images/temp_'+
val.indexOf(i)+'.gif">';
}
document.all.ImgTemp.innerHTML=str;
}
</script>
<body onload="InitTemp()">
<input type="hidden" id="temperature" value="20">
<input type="button" value="升温" onClick="ChgTemp(1)">
<input type="button" value="降温" onClick="ChgTemp(-1)">
<div id="ImgTemp"></div>
[此贴子已经被作者于2006-8-21 14:45:58编辑过]