日期:2014-05-16  浏览次数:20346 次

关于alert()
我想做个乘法表     请问大家如何用alert()   弹出对话框一次性显示出9*9乘法表呢
那个document.write()就不用了我想知道用alert()怎么写

谢谢大家了

------解决方案--------------------
<script>
txt = " ";
for(C=1; C <=9; C++)
{
for(c=1; c <=9; c++)
{
txt += C+ "× "+c+ "= "+C*c+ " ";
}
txt += "\n ";
}
alert(txt);
</script>
------解决方案--------------------
[个人意见,仅供参考]

<script language= "javascript ">
function Create99Table(){
var str = " ";
for(var i=1; i <10; i++){
for(var j=i;j <10; j++){
str += String(i) + '* ' + String(j) + '= ' + String(i*j*1)+ '\t '
}
str += '\n '
}
return str;
}

var s = Create99Table();
alert(s)
</script>
------解决方案--------------------
<script>
s = " ";
for(var i=1;i <=9;i++){
for(var j=1;j <=i;j++){
s += i + "* " + j + "= " + (i*j) + " ";
}
s += "\n ";
}
alert(s)
</script>