用javascript写,显示在html网页上

输出一个数值表格,内容为2到5,以及它们对应的平方和立方,用循环语句实现。
输入:利用prompt逐个输入三个数值;输出:这三个数值中的最大值。

刚开始学,求指导

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<script type="text/javascript">
 var tab ='<table>';
 for ( var i = 2; i <= 5; i++ ) {
  var j = i;
  tab += '<tr><td>' + i + '<\/td><td>' + ( j*j ) + '<\/td><td>' + ( j*j*j) + '<\/td><\/tr>';
 }
     tab += '<\/table>';
     document.write( tab );
</script>
</body>
</html>

这个是输出表格的

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript">
 var a = prompt('请输入第一个数字:', 0 ), b = prompt('请输入第二个数字:', 0 ), c = prompt('请输入第三个数字:', 0 ), d = Math.max( a, b ), e = Math.max( c, d );
 alert('您输入的最大的数是:'  + e );
</script>
</body>
</html>

 这个是求最大数的

追问

谢谢~

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-10-16
<html>
<head>
<script type="text/javascript">
function disp_prompt()
  {
  var num1=prompt("Please enter the first number","");
  var num2=prompt("Please enter the second number","");
  var num3=prompt("Please enter the third number","");
  
document.write("这三个数值中的最大值是:"+Math.max(num1,num2,num3))
  }
</script>
</head>
<body>

<input type="button" onclick="disp_prompt()"
value="Display a prompt box" />

</body>
</html>

追问

能用!太感谢了! 请问“输出一个数值表格,内容为2到5,以及它们对应的平方和立方,用循环语句实现。”这个能指导一下吗?

追答

肯定可以用啊,我测试过了的

追问

最佳只能给一人,但是真的特别感谢你!你的这个也是能用的,界面更友好。

相似回答