唉,今年十一没地方玩,也没有MM陪,特意买了三本JS书回来学,遇到一个难题,请大家帮我解释一下,<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transiteonal.dtd">
<html xmlns="http://www.w3.org.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>td</title>
</head><body><table border="1">
<tr>
<?php
for ($i=0;$i<5;$i++){
echo "<th width='30'>".($i+1)."</th>\n";
}
echo "<tr>";
for ($i=1;$i<=25;$i++){
echo "<td id='td".$i."'></td>\n";
if ($i % 5 ==o){
echo "</tr>bb<tr>\n";
}
}
?>
</tr>
</table><script type="text/javascript">
window.onload=bb;function bb(){
if (document.getElementById){
document.getElementById("check").onclick=setsum;
newcard();
}else{
alert("sorry,your browser doesn't support this script!");
}
}function newcard(){
for (var i=1;i<=25;i++){
settd(i);
}
}var emptysum=new Array(76);
function settd(x){
var tds="td"+x;
var colpace=new Array(0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4);
var sum=(colpace[x-1]*15);
var sums
do {
sums=sum+getsum();
}while (emptysum[sums])
emptysum[sums]=true;
document.getElementById(tds).innerHTML=sums;
}function getsum(){
return Math.floor(Math.random()*15)+1;
}function setsum(){
for (var i=0;i<emptysum.length;i++){
emptysum[i]=false;
}
newcard();
return false;
}
</script><a href="aa.asp" id="check">onclick here</a></body>
</html>
=============================================================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transiteonal.dtd">
<html xmlns="http://www.w3.org.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>td</title>
</head><body><table border="1">
<tr>
<?php
for ($i=0;$i<5;$i++){
echo "<th width='30'>".($i+1)."</th>\n";
}
echo "<tr>";
for ($i=1;$i<=25;$i++){
echo "<td id='td".$i."'>bb</td>\n";
if ($i % 5 ==o){
echo "</tr><tr>\n";
}
}
?>
</tr>
</table><script type="text/javascript">
window.onload=bb;function bb(){
if (document.getElementById){
document.getElementById("check").onclick=newcard;
setsum();
}else{
alert("sorry,your browser doesn't support this script!");
}
}function newcard(){
for (var i=1;i<=25;i++){
settd(i);
}
return false;
}var emptysum=new Array(76);
function settd(x){
var tds="td"+x;
var colpace=new Array(0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4);
var sum=(colpace[x-1]*15);
var sums
do {
sums=sum+getsum();
}while (emptysum[sums])
emptysum[sums]=true;
document.getElementById(tds).innerHTML=sums;
}function getsum(){
return Math.floor(Math.random()*15)+1;
}function setsum(){
for (var i=0;i<emptysum.length;i++){
emptysum[i]=false;
}
}
</script><a href="aa.asp" id="check">onclick here</a></body>
</html>
===========================================================
前面的正常,后面不知道哪里错了,请大家帮忙解释下!