日期:2014-05-17 浏览次数:20525 次
<?php echo "<input type='text' id='round' value=''/>"; echo "<input type='button' id='submit' value='Submit' onclick='javascript:getArea()'>"; echo "<p id='area'></p>"; ?> <script> var round; var area; var PI = 3.14; function getArea() { round = parseFloat(document.getElementById("round").value); area = 4/3*PI*round*round; setArea(area); } function setArea(area) { document.getElementById("area").innerHTML = "The Round's Area is : "+area ; } </script>
------解决方案--------------------
$area = 0; if(isset($_GET['r'])) $area = pi()*$_GET['r']*$_GET['r']; echo <<< HTML <form> 半径<input type=text name=r> <input type=submit value=计算> </form> 面积=$area HTML;