带有输入框和确认按钮的表单
本例演示如何向页面添加表单。此表单包含两个输入框和一个确认按钮。
<html>
<body>
<form action="http://www.w3school.com.cn/example/html/form_action.asp" method="get">
<p>First name: <input type="text" name="fname" /></p>
<p>Last name: <input type="text" name="lname" /></p>
<input type="submit" value="Submit" />
</form>
<p>请单击确认按钮,输入会发送到服务器上名为 "form_action.asp" 的页面。</p>
</body>
</html>
05 | < p >First name: < input type = "text" name = "fname" /></ p > |
06 | < p >Last name: < input type = "text" name = "lname" /></ p > |
07 | < input type = "submit" value = "Submit" /> |
10 | < p >请单击确认按钮,输入会发送到服务器上名为 "form_action.asp" 的页面。</ p > |
带有复选框的表单
此表单包含两个复选框和一个确认按钮。
<html>
<body>
<form name="input" action="http://www.w3school.com.cn/html/html_form_action.asp" method="get">
I have a bike:
<input type="checkbox" name="vehicle" value="Bike" checked="checked" />
<br />
I have a car:
<input type="checkbox" name="vehicle" value="Car" />
<br />
I have an airplane:
<input type="checkbox" name="vehicle" value="Airplane" />
<br /><br />
<input type="submit" value="Submit" />
</form>
<p>如果您点击 "Submit" 按钮,您将把输入传送到名为 html_form_action.asp 的新页面。</p>
</body>
</html>
07 | < input type = "checkbox" name = "vehicle" value = "Bike" checked = "checked" /> |
10 | < input type = "checkbox" name = "vehicle" value = "Car" /> |
13 | < input type = "checkbox" name = "vehicle" value = "Airplane" /> |
15 | < input type = "submit" value = "Submit" /> |
18 | < p >如果您点击 "Submit" 按钮,您将把输入传送到名为 html_form_action.asp 的新页面。</ p > |
带有单选按钮的表单
此表单包含两个单选框和一个确认按钮。
<html>
<body>
<form name="input" action="http://www.w3school.com.cn/html/html_form_action.asp" method="get">
Male:
<input type="radio" name="Sex" value="Male" checked="checked">
<br />
Female:
<input type="radio" name="Sex" value="Female">
<br />
<input type ="submit" value ="Submit">
</form>
<p>如果您点击 "Submit" 按钮,您将把输入传送到名为 html_form_action.asp 的新页面。</p>
</body>
</html>
07 | < input type = "radio" name = "Sex" value = "Male" checked = "checked" > |
10 | < input type = "radio" name = "Sex" value = "Female" > |
12 | < input type = "submit" value = "Submit" > |
15 | < p >如果您点击 "Submit" 按钮,您将把输入传送到名为 html_form_action.asp 的新页面。</ p > |
从表单发送电子邮件
此例演示如何从表单发送电子邮件。
<html>
<body>
<form action="MAILTO:someone@w3school.com.cn" method="post" enctype="text/plain">
<h3>这个表单会把电子邮件发送到 W3School。</h3>
姓名:<br />
<input type="text" name="name" value="yourname" size="20">
<br />
电邮:<br />
<input type="text" name="mail" value="yourmail" size="20">
<br />
内容:<br />
<input type="text" name="comment" value="yourcomment" size="40">
<br /><br />
<input type="submit" value="发送">
<input type="reset" value="重置">
</form>
</body>
</html>
04 | < form action = "MAILTO:someone@w3school.com.cn" method = "post" enctype = "text/plain" > |
06 | < h3 >这个表单会把电子邮件发送到 W3School。</ h3 > |
08 | < input type = "text" name = "name" value = "yourname" size = "20" > |
11 | < input type = "text" name = "mail" value = "yourmail" size = "20" > |
14 | < input type = "text" name = "comment" value = "yourcomment" size = "40" > |
16 | < input type = "submit" value = "发送" > |
17 | < input type = "reset" value = "重置" > |