代码块的隐藏
来源:互联网 发布:树莓派怎样编程 编辑:程序博客网 时间:2024/06/05 14:32
方法一·<input type="hidden" name="doing" value="work">
Cat.php
<form action="CatWork.php" method="post">
<h1>四则运算</h1>
第一个数:<input type="text" name="num1"><br>
第二个数:<input type="text" name="num2"><br>
运算符号:
<select name="oper">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select><br>
//隐藏域的使用
<input type="hidden" name="doing" value="work">
<input type="submit" value="开始计算">
</form>
<br>
<form action="CatWork.php" method="post">
<h1>计算圆形面积</h1>
请输入半径:<input type="text" name="radius"><br>
<input type="submit" value="开始计算面积">
//隐藏域的使用
<input type="hidden" name="doing" value="area">
</form>
<form action="CatWork.php" method="post">
<h1>长方形的面积</h1>
长:<input type="text" name="length"><br>
宽:<input type="text" name="width"><br>
隐藏域的使用
<input type="hidden" name="doing" value="rectangle"><br>
<input type="submit" value="开始计算">
</form>
CatWork.php
<?php
require_once 'CatClass.php';
$doing=$_REQUEST['doing'];
$cat=new Cat();
if($doing=="work"){
$num1=$_REQUEST['num1'];
$num2=$_REQUEST['num2'];
$oper=$_REQUEST['oper'];
echo '计算结果:'.$cat->work($num1,$num2,$oper)."<br>";
}elseif($doing=="area"){
$radius=$_REQUEST['radius'];
echo '计算面积是'.$cat->circleArea($radius);
}elseif($doing=="rectangle"){
$length=$_REQUEST['length'];
$width=$_REQUEST['width'];
//var_dump($length,$width);
echo '长方形的面积是:'.$cat->rectangleArea($length,$width);
}
echo "<br>";
echo "<a href='Cat.php'>返回主页</a>";
?>
CatWork.php
<?php
header("content-type:text/html;charset=utf8");
class Cat{
$res=0;
function work($num1,$num2,$oper){
if($oper=="+"){
$res=$num1+$num2;
}elseif($oper=="-"){
$res=$num1+$num2;
}elseif($oper=="*"){
$res=$num1*$num2;
}elseif($oper=="/"){
$res=$num1/$num2;
}
return $res;
}
function circleArea($radius){
return 3.14*$radius*$radius;
}
function rectangleArea($l,$w){
return $l*$w;
}
}
?>
方法二·
<html>
<head>
<meta http-equiv="content-type" content="text/html charset=utf-8">
<script language="javascript">
function selType(val){
//window.alert("你选中"+val);
if(val=="jisuan"){
table1.style.display="block";
table2.style.display="none";
}else if(val=="area"){
table1.style.display="none";
table2.style.display="block";
}
}
</script>
</head>
<h1>聪明的猫</h1>
<form action="CatWork.php" method="post">
<input type="radio" name="sel" onclick="selType('jisuan')">四则运算
<input type="radio" name="sel" onclick="selType('area')">计算矩形
<table id="table1" style="display:black">
<tr><td>第一个数</td><td><input type="text" name="num1"></td></tr>
<tr><td>第二个数</td><td><input type="text" name="num2"></td></tr>
<tr><td>运算符号</td>
<td>
<select name="oper">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
</td>
</tr>
<tr><td colspan="2"><input type="submit" value="四则运算"></td></tr>
</table>
<table id="table2" style="display:none">
<tr><td>长</td><td><input type="text" name="length"></td></tr>
<tr><td>宽</td><td><input type="text" name="width"></td></tr>
<tr><td colspan="2"><input type="submit" value="矩形运算"></td></tr>
</table>
</form>
</html>
2 0
- 代码块的隐藏
- 隐藏特性:Java的初始化代码块
- VS Code 隐藏代码块的参考虚线
- 代码块的使用
- 代码块的使用
- 代码块的调用
- 代码块{}的使用
- Java的代码块
- JAVA的代码块
- Java的代码块
- 代码块的学习
- 有用的代码块
- Java的代码块
- ruby 的代码块
- 代码块的测试
- java的代码块
- 静态代码块 初始化块 代码块的区别
- java的代码块优先级 (静态代码块,构造代码块,普通代码块)
- iis7 发布mvc3 遇到的HTTP错误 403.14-Forbidden Web 服务器被配置为不列出此目录的内容及Login on failed for "IIS APPPOOL\ASP.NET
- Systemd 入门教程:命令篇
- 程序员装逼指南
- orace后台执行
- 图表控件,官方AchartEngine控件学习
- 代码块的隐藏
- jQuery:this与$(this)的差別
- 剑指offer之面试题36数组中的逆序对
- bzoj 3822: 文学 动态规划
- apache + httpclient4 + jsoup 进行模拟浏览器url访问
- Systemd 入门教程:实战篇
- CentOS7中安装subversion
- JS中数组去重及求量数组中的相同字符个数
- 苏宁易购亿万级商品评价系统的架构演进之路和实现细节