请清除circlecaluclator按钮上的错误 [英] please remove error at circlecaluclator button

查看:78
本文介绍了请清除circlecaluclator按钮上的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html>
<head>
  <title>CALUCLATING AREA AND PERIMETER</title>
<center><h1>CALUCLATOR FOR AREA & PERIMETER</h1></center>

  <style>
  
  </style>

  <script language="JavaScript">

    var x = new Array();
    var y = new Array();
    var vertices;
    var digits;
    var area;
    var perimeter;
    var r;
    var carea;
    var cperi;
    
    function readUserData()
    {
        
        vertices = parseInt( document.getElementById("VERTICES").value );
        if( (vertices < 2) || (vertices > 10 ) ) {
            alert( "Vertices must be >= 2 and <= 10" );
            return;
        }

       

        
       
        for( k = 0; k < vertices; k++ ) {
            x[k] = parseInt( document.getElementById("X"+k).value );
            y[k] = parseInt( document.getElementById("Y"+k).value );
        }
        
        x[vertices] = x[0];
        y[vertices] = y[0];
    }

    function calculateArea()
    {
        
        area = 0.0;
        for( k = 0; k < vertices; k++ ) {
            xDiff = x[k+1] - x[k];
            yDiff = y[k+1] - y[k];
            area = area + x[k] * yDiff - y[k] * xDiff;
        }
        area = 0.5 * Math.abs(area);
    }

    function calculatePerimeter()
    {
        

        perimeter = 0.0 
        for( k = 0; k < vertices-1; k++ ) {
            xDiff = x[k+1] - x[k];
            yDiff = y[k+1] - y[k];
            perimeter = perimeter + 
                        Math.pow( xDiff*xDiff + 
                        yDiff*yDiff, 0.5 );
        }
    }
function cir()
 {
 r= parseInt(document.getElementById("Y"+10).value);
 carea=3.1429*(r*r);
 cperi=6.2858*r;
alert(" circle area is "+carea);
alert(" circle perimeter is"+cperi);
}

    

    function handleCalculate()
    {
        readUserData();
        calculateArea();
        calculatePerimeter(); 
    
        alert("area is  "+area);
        alert("PERIMETER IS  "+perimeter);

    }

   
  </script>
</head>

<body>
<div align="center">
<div class="content">
<form>
<table border="2" cellspacing="0">
         cellpadding="2" style="border-collapse: collapse">

<tr>
<td colspan="2">Number of Vertices 
<input type="text" id="VERTICES" 
          size="5" value="0"></td>

</tr>
<tr>
<td align="center">Vertex</td>
<td colspan="2" align="left">X Value</td>
<td align="left">Y Value</td>
</tr>
<tr>
<td align="center">1</td>
<td colspan="2"><input type="text" 
               id="X0" size="20"></td>
<td><input type="text" id="Y0" size="20"></td>
</tr>
<tr>
<td align="center">2</td>
<td colspan="2"><input type="text" 
             id="X1" size="20"></td>
<td><input type="text" id="Y1" size="20"></td>
</tr>
<tr>
<td align="center">3</td>
<td colspan="2"><input type="text" 
             id="X2" size="20"></td>
<td><input type="text" id="Y2" size="20"></td>
</tr>
<tr>
<td align="center">4</td>
<td colspan="2"><input type="text" 
            id="X3" size="20"></td>
<td><input type="text" id="Y3" size="20"></td>
</tr>
<tr>
<td align="center">5</td>
<td colspan="2"><input type="text" 
           id="X4" size="20"></td>
<td><input type="text" id="Y4" size="20"></td>
</tr>
<tr>
<td align="center">6</td>
<td colspan="2"><input type="text" 
          id="X5" size="20"></td>
<td><input type="text" id="Y5" size="20"></td>
</tr>
<tr>
<td align="center">7</td>
<td colspan="2"><input type="text" 
         id="X6" size="20"></td>
<td><input type="text" id="Y6" size="20"></td>
</tr>
<tr>
<td align="center">8</td>
<td colspan="2"><input type="text" 
         id="X7" size="20"></td>
<td><input type="text" id="Y7" size="20"></td>
</tr>
<tr>
<td align="center">9</td>
<td colspan="2"><input type="text" 
         id="X8" size="20"></td>
<td><input type="text" id="Y8" size="20"></td>
</tr>
<tr>
<td align="center">10</td>
<td colspan="2"><input type="text" 
         id="X9" size="20"></td>
<td><input type="text" id="Y9" size="20"></td>
</tr>

<tr>
<td align="center"><input type="button" 
    value="Calculate"  önClick="handleCalculate()"></td>

<td align="center">
<input type="reset" value="Reset"></td>
</tr>
<tr><td>for circle:</td></tr>
<tr><td>ENTER radius <input type="text" id="Y10" size="20"></td></tr>
<tr><td><input type="submit" value="circleCaluclator"  önSubmit="cir()"></td></tr>

</form>
</table></div>
</div>
</body>
</html>

推荐答案

将onSubmit()替换为onClick()
然后检查您的答案
replace onSubmit() with onClick()
and now check ur answer


这篇关于请清除circlecaluclator按钮上的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆