<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
function order() {
var name = document.getElementById("xm").value;
if (name == "") {
alert("请输入姓名");
return;
}
var sex = document.getElementsByName("xb");
var sexValue = "";
for (let i = 0; i < sex.length; i++) {
if (sex[i].checked == true) {
sexValue = sex[i].value;
}
}
var fruits = document.getElementsByName("fruit");
var orders = ""
for (let i = 0; i < fruits.length; ++i) {
if (fruits[i].checked == true) {
if(orders != "") {
orders += ", ";
}
orders += fruits[i].value;
}
}
var info = document.getElementById("info");
if (orders == "") {
info.innerHTML="你没有订购任何水果。";
} else {
info.innerHTML="姓名:" + name + "<br>性别:" + sexValue + "<br>你订购了:"
+ orders;
}
}
</script>
</head>
<body>
<h1>实验一:Javascript与html基础</h1>
<h2>订购水果</h2>
<form action="" method="POST" name="theForm">
姓名:
<input id="xm" type="text" size="20" maxlength="10">
性别:
<input name="xb" type="radio" value="男" checked> 男
<input name="xb" type="radio" value="女"> 女<br>
选择需要的水果
<hr>
<input name="fruit" type="checkbox" value="苹果">苹果<br>
<input name="fruit" type="checkbox" value="香蕉">香蕉<br>
<input name="fruit" type="checkbox" value="菠萝">菠萝<br>
<input name="fruit" type="checkbox" value="橘子">橘子<br>
<input name="fruit" type="checkbox" value="樱桃">樱桃
<hr>
<button type="button" value="订购" onclick="order()">订购</button>
</form>
<hr>
<div id="info"></div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form action="" method="post" name="form333">
input n:<input name="n" type="text" id="n" maxlength="5"><p>
<input name="button" type="button" value="计算" onClick="cal();">
result :
<input name="result" type="text" readonly="true" id="result
">
</form>
<hr color="#3333CC">
<script language="javascript" type="text/javascript">
function cal()
{
x=document.form333.n.value;
if(!isNaN(x) && x>=1)
{
var i,y=0;
for(i=1;i<x;i++){y=y+i;}
document.form333.result.value =y;
}
else
{ document.form333.result.value = "输入的n 不合法";
}
}
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<img src="../php/sy2-1.jpg" width="810" height="468" />
<hr />
<?php
$x=$_GET["x"];
if($x>10){
$y =$x*$x +0.5;
}else if($x<=10){
$y =$x*$x +0.5;
}else{
$y =$x*$x +0.5;
}
echo "x = $x, y = $y";
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<img src="../php/sy2-1.jpg" width="810" height="468" />
<hr />
<form action="sy 2-1 demo1.php" method="get">
input :<input name="x" type="text"/>
<input type="submit" value="提交" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<table width="700" border="1" cellspacing="2" cellpadding="0">
<?php
for($r=1;$r<=8;$r++){
if($r%2==0){
$ys = "#FFFFFF";
}else{
$ys = "#00FF66";}
?>
<tr bgcolor=<?php echo $ys; ?>>
<?php for($c=1;$c<=5;$c++){ ?>
<td align="center">江龙杰大帅哥</td>
<?php }?>
</tr>
<?php } ?>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<?php
$c1=1;$y=2017; $n=0;
while($c1 <2)
{
$c1 =$c1 *1.2;
$y++;
$n++;
echo "$n -----{$y}年,
产量:$c1<br>";
}
?>
</body>
</html>