本人对后台不是太了解,所以这里做成了用户自己输入参数的办法来模拟从后台读参数的过程。 复制代码 代码如下: <BR>*{margin:0; padding:0;} <BR>.uInfo{width:200px; padding:10px;} <BR>h3{margin:10px 0;} <BR>#level{width:150px; height:6px; border:1px solid #ccc; cursor:pointer;} <BR>#le{height:6px; width:0;display:block; background:#f00; font-size:0;} <BR>label{margin-left:10px;} <BR>#showTime{display:none; color:#f00; line-height:24px; font-size:12px;} <BR> <BR>function userInfo(){ <BR>var allTime = document.getElementById("allTime").value; <BR>var onTime = document.getElementById("onTime").value; <BR>var level = document.getElementById("level"); <BR>var le = document.getElementById("le"); <BR>if(allTime == onTime){ <BR>le.style.width = 100+"%"; <BR>} <BR>else if(onTime == 0){ <BR>le.style.width = 0; <BR>} <BR>else{ <BR>countPercent(onTime,allTime,level,le); <BR>} <BR>} <BR>function countPercent(onHours,allHours,level,le){ <BR>var floatNum = onHours/allHours; <BR>var percent = floatNum.toFixed("2"); <BR>var toPercent; <BR>if(percent == 1.00){ <BR>toPercent = 99; <BR>} <BR>else if(percent == 0.00){ <BR>toPercent = 1; <BR>} <BR>else{ <BR>toPercent = percent.substring(2); <BR>} <BR>le.style.width = toPercent+"%"; <BR>var showTime = document.getElementById("showTime"); <BR>level.onmouseover = function(){ <BR>showTime.style.display = "block"; <BR>showTime.innerHTML = "在线时长:" + onHours +"/"+ allHours; <BR>} <BR>level.onmouseout = function(){ <BR>showTime.innerHTML = ""; <BR>showTime.style.display = "none"; <BR>} <BR>} <BR> 用户等级 在线时间:本级所需时间: