最近給公司做了個投票系統,不過投票結果顯示是用flash做的HOHO
全都是動態餅圖,主圖,還有曲線圖
但是看到國外有用js寫的動態效果於是自己寫了個小例子HOHO
<html>
<script language="javascript">
/**
* 動態設定大小
* @param obj_id,動態顯示div的id
* @param max,最大票數
* @madeby ok7758521ok <ok7758521ok@126.com>
*/
function setautoSize(obj_id,max)
{
var obj_item = document.getElementById(obj_id);
len = obj_item.style.width.length - 2;
cur = obj_item.style.width.substring(0,len);
//alert(cur);
if( cur < max)
{
cur++;
document.getElementById(obj_id+"_value").innerHTML=cur+"%";
obj_item.style.width= cur+"px";
window.setTimeout("setautoSize('"+obj_id+"',"+max+")",10);
}
else
{
alert(obj_id+"ok");
}
}
//JS調用方式HOHO
window.setTimeout("setautoSize('item0',300)",10);
window.setTimeout("setautoSize('item1',100)",10);
</script>
<body>
<div id="item0_value"></div><div id="item0" style="overflow: hidden; width: 1px;height:10px;background-color:#000fff;}"></div>
<br>
<div id="item1_value"></div><div id="item1" style="overflow: hidden; width: 1px;height:10px;background-color:#10ff00;}"></div>
</body>
</html>