<html>
<head>
<title>阶乘</title>
<script language="javascript">
                     function factorial(){
                               var total=2,temp;
                          for(temp=arguments;temp<=arguments[1];temp++){
                  total*=temp;
                     }
                         return tempt;
          }
</script>
</head>
<body style="font-size:12px">
  <form name="myform">
   <p>请输入一个数: <input type="text" name="first" size=6>       
   <p>阶乘是: <input type="text" name="second" size=6> 
   <p><input type="button" onclick="factorial()" value="计算">&nbsp;
<input type="text" name="result" size=6> 
</form>
</body>
</html>
                           我想点击“计算”按钮调用该函数,可是在IE6中没有显示结果,
     这段代码也不知道是哪里错了。请教高手指点。在线等!

解决方案 »

  1.   

    <script language="javascript">
      function factorial(){
      var total=2,temp;
      for(temp=arguments;temp<=arguments[1];temp++){
      total*=temp;
      }
      var a = document.getElementsByTagName('result')[0];
      
    a.value =tempt;
      }
    </script>
      

  2.   

    哦 错了  function factorial(){
      var total=2,temp;
      for(temp=arguments;temp<=arguments[1];temp++){
      total*=temp;
      }
      var a = document.getElementsByTagName('result')[0];
      
    a.value =tempt;
      }
      

  3.   

    gaicheng 
     function factorial(){
      var total=2,temp;
      for(temp=arguments;temp<=arguments[1];temp++){
      total*=temp;
      }
      var a = document.getElementsByName('result')[0];
      
    a.value =tempt;
      }
      

  4.   

    factorial()这个函数要传参的吧,我是新手,不对见谅!
      

  5.   

    嗯 是的 不过 arguments是有的
    因为这个是在function中自带的。我刚才没仔细看代码 他的function调用的时候没带参数
    等下 我重新写下
      

  6.   

    <html>
    <head>
    <title>阶乘</title>
    <script language="javascript">
      function factorial(){
      var tmp = document.getElementsByTagName('form')[0];
      var total=2,temp;
      for(temp=2; temp <= tmp.elements["first"].value;temp++){
      total *= temp;
      }
         tmp.elements["result"].value = total  return false;
      }
    </script>
    </head>
    <body style="font-size:12px">
      <form name="myform">
      <p>请输入一个数: <input type="text" name="first" size=6>   
      <p>阶乘是: <input type="text" name="second" size=6>  <!--阶乘不需要输入2个数字吧!-->
      <p><input type="button" onclick="factorial()" value="计算">&nbsp;
    <input type="text" name="result" size=6>  
    </form>
    </body>
    </html>
    在first里输入个数字 点按钮就可以了
      

  7.   

    thank you!弄好了  ,也明白怎么弄了  。谢谢大家!
      

  8.   

    <html>
    <head>
    <title>阶乘</title>
    <script language="javascript">
      function factorial(){
      var tmp = document.getElementsByTagName('form')[0];
      var total=1,temp;
      for(temp=1; temp <= tmp.elements["first"].value;temp++){
          total *= temp;
      }
            tmp.elements["result"].value = total  return false;
      }
    </script>
    </head>
    <body style="font-size:12px">
      <form name="myform">
      <p>请输入一个数: <input type="text" name="first" size=6>   
      
      <p><input type="button" onclick="factorial()" value="计算">&nbsp;
    <input type="text" name="result" size=6>  
    </form>
    </body>
    </html>   这是我要的效果  关于上面的那个大哥所写的temp=2和total=2
    应高把2改写成1 ,这样结果才是对的。