<!DOCTYPE html> <html> <body> <form action="/demo/demo_form.asp"> First name:<br> <input type="text" name="firstname" value="Mickey"> <br> Last name:<br> <input type="text" name="lastname" value="Mouse"> <br><br> <input type="submit" value="Submit"> </form> <p>如果您点击提交,表单数据会被发送到名为 demo_form.asp 的页面。</p> </body> </html>
<!--表单-->
列表框
<!DOCTYPE html> <html> <body> <select> <option>Volvo</option> <option>Saab</option> <option>Mercedes</option> <option>Audi</option> </select> </body> </html>
向上移,
<html> <head> <script type="text/javascript"> function setFocus() { document.getElementById('text1').focus() } function loseFocus() { document.getElementById('text1').blur() } </script> </head> <body> <form> <input type="text" id="text1" /> <br /> <input type="button" onclick="setFocus()" value="Set focus" /> <input type="button" onclick="loseFocus()" value="Lose focus" /> </form> </body> </html>
按钮
<html> <body> <button type="button">Click Me!</button> </body> </html>
提交
<html> <head> <script type="text/javascript"> function formSubmit() { document.getElementById("myForm").submit() } </script> </head> <body> <p>在下面的文本框中输入一些文本,然后点击提交按钮就可以提交表单。</p> <form id="myForm" action="/i/eg_smile.gif" method="get"> 名:<input type="text" name="firstname" size="20"><br /> 姓:<input type="text" name="lastname" size="20"><br /> <br /> <input type="button" onclick="formSubmit()" value="提交"> </form> </body> </html>
单选选择
<html> <body> <p>请点击文本标记之一,就可以触发相关控件:</p> <form> <label for="male">Male</label> <input type="radio" name="sex" id="male" /> <br /> <label for="female">Female</label> <input type="radio" name="sex" id="female" /> </form> </body> </html>
多行文本域
<textarea name="textarea" cols="显示的列数" rows="显示的行数"> 文本内容 </textarea>
文件域
<form action="" method="post" enctype="multipart/form-data"> <p> <input type="file" name="files"/><br/> <input type="submit" name="upload" value="上传“/> </p> </form> <!--在不同的浏览器显示的效果不一样-->
URL地址格式
<form action=""method="post"> <p> 输入你的网址: <input type="url" name="userUrl"/> </p> <input type="submit"/> </form>
number数字
<form action="#“ method="post"> <p> 请输入数字: <input type="number" name="um" min="0" max="最大值" step="最小值”/> </p> <input type="submit"/> </form>