html--form表单

<!-- form 标签

    作用:收集并提交用户的信息

    属性:

       id     表单的id,用于js获取表单

       name 表单的名字,用于js获取表单

       action 表单提交的地址

       method 表单提交的方式,常用值为get和post

          get(默认)

          post

       enctype 表单中数据的编码方式

          application/x-www-form-urlencoded(默认)

          multipart/form-data

          text/plain

     form标签的子标签(表单域)

        注意:1.对于所有的子标签来讲,只有添加name属性,才可以提交!

           2.一般来讲,value属性就是提交的值

           3.对于radio和checkbox而言,如果没有设定value属性,则提交时值为on

           4.对于select而言,select提交的值就是option标签的value属性值,如果option标签没有设定value属性值时,默认提交option标签中间的文本值

           5.对于textarea而言,textarea提交的值不是value属性,而是标签中间的文本数据

           6.对于三个按钮来讲,input和button从本质来讲并无区别,而且一般情况不用设置name属性(即不用提交)

        input 属性

          type="text"    文本框

          type="password"  密码框

          type="hidden"    隐藏框

          type="file"     文件框

          type="radio"     单选按钮

            name属性相同即为一组

          type="checkbox"   复选框

            name属性相同即为一组

          对于input type="radio"和input type="checkbox"来讲,添加check="check"属性表示默认选中该选项

          type="submit"    提交按钮,提交表单

          type="reset"      重置按钮,重置表单

          type="button"    普通按钮,用于被js调用

          对于input type="submit"、input type="reset"和input type="button"来讲,value属性表示按钮上的文字

      select   下拉列表框

        给select添加multiple="multiple"的属性后,就变成多选

        需要和option标签一起使用

      textarea  多行文本域

      button  按钮

-->

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <form action="http://www.baidu.com" method="get" enctype="application/x-www-form-urlencoded"> 用户名:<input type="text" name="username" placeholder="请填写用户名"/><br/> 密码:<input type="password" name="pwd"/><br/> <input type="hidden"e="hiddenfile"/><br/> <input type="file" name="file"/><br/> 性别:<label for="women">女</label><input id="women" type="radio" name="gender" value=""/> <label for="man">男</label><input id="man" type="radio" name="gender" value=""><br/> 篮球 <input type="checkbox" name="sports" value="篮球"/> 足球<input type="checkbox" name="sports" value="足球"/> <br/> <select name="city"> <option value="广州">广州</option> <option value="深圳">深圳</option> <option value="佛山">佛山</option> </select> <textarea name="inc" cols="30" rows="10">滴滴……</textarea> <input type="button"/><input type="submit"/><input type="reset"/> <button type="submit">提交</button> <button type="reset">重置</button> <button type="button">普通</button> </form> </body> </html>
原文地址:https://www.cnblogs.com/cqming/p/10770513.html