Home > Backend Development > PHP Tutorial > 求一段用php代码,该怎么解决

求一段用php代码,该怎么解决

WBOY
Release: 2016-06-13 10:38:09
Original
825 people have browsed it

求一段用php代码
求一段用php代码,网页上有个输入框,输入半径之后,点击按钮求圆的面积

------解决方案--------------------

PHP code
<?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><br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
$area = 0;if(isset($_GET['r'])) $area = pi()*$_GET['r']*$_GET['r'];echo 半径<input type="text" name="r"><input type="submit" value="计算">面积=$areaHTML;<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template