fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <script> function createOrder(){ var coffee=document.forms[0].coffee; var txt=""; var i; for (i=0;i<coffee.length;i++){ if (coffee[i].checked){ txt=txt + coffee[i].value + " "; } } document.getElementById("order").value="你点了咖啡: " + txt; } </script> </head> <body> <p>你喜欢什么样的咖啡?</p> <form> <input type="checkbox" name="coffee" value="加冰">加冰<br> <input type="checkbox" name="coffee" value="加糖">加糖<br> <br> <input type="button" onclick="createOrder()" value="发送订单"> <br><br> <input type="text" id="order" size="50"> </form> </body> </html>
运行结果