案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
function createOrder()
5
{
6
coffee=document.forms[0].coffee
7
txt=""
8
for (i=0;i<coffee.length;++ i)
9
{
10
if (coffee[i].checked)
11
{
12
txt=txt + coffee[i].value + " "
13
}
14
}
15
document.getElementById("order").value="您订购的咖啡带有: " + txt
16
}
17
</script>
18
</head>
19
20
<body>
21
<p>你喜欢怎么喝咖啡?</p>
22
<form>
23
<input type="checkbox" name="coffee" value="奶油">加奶油<br />
24
<input type="checkbox" name="coffee" value="糖块">加糖块<br />
25
<br />
26
<input type="button" onclick="createOrder()" value="发送订单">
27
<br /><br />
28
<input type="text" id="order" size="50">
29
</form>
30
</body>
31
32
</html>
33