tension 2008-4-2 08:32
用星投票的示例(无图片)
[html]
<html>
<head>
<title>用星投票的示例(无图片) - pickbar.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
var nowindex = 1; //默认几个星
var startnum = 10; //星的个数
var selectedcolor = "red"; //选上的颜色
var uselectedcolor = "gray";//未选的颜色
function _$(id)
{
return document.getElementById(id);
}
function setstar(index)
{
for(var i=1;i<=index;i++){
_$("s"+i).style.color=selectedcolor;
_$("s"+i).style.cursor="hand";
}
for(var i=(index+1);i<=startnum;i++){
_$("s"+i).style.color=uselectedcolor;
_$("s"+i).style.cursor="hand";
}
}
function initstar()
{
for(var i=1;i<=startnum;i++){
document.write('<span id="s'+i+'" onclick="clickstar('+i+')" title="'+i+'星" onmouseout="setstar(nowindex)" onmouseover="setstar('+i+')">★</span>');
}
setstar(nowindex)
}
function clickstar(index)
{
alert(index+"星");
}
//-->
</SCRIPT>
<div style="font-size:48pt;">
<SCRIPT LANGUAGE="JavaScript">
<!--
initstar()
//-->
</SCRIPT>
</div>
</body>
</html>
[/html]