for ( i=1 i<=9 i++ ){
for( j=1 j<=i j++ )
document.write( i + "x" + j + "=" + i*j + " ")
document.write("<br>") //这里输出一个换行符<br>,可能会被系统吃掉
}
</script>
结果:
用onkeyup效果能好点吧 一下---------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=GB18030">
<title>Insert title here</title>
</head>
<script type="text/javascript">
function account()
{
var a=document.all.a.value
var b=document.all.b.value
var c=a*b
document.all.c.value=c
}
</script>
<body>
单价:<input id="a" type="text" value="60">
数量:<input id="b" type="text" onkeyup="account()">
总和 <input id="c" type="text">
<input type="button" onclick="account()" value="计算">
</body>
</html>