17. HTML 表单和输入

一:

    定义: 表单是一个包含表单元素的区域。

             表单元素是允许用户在表单中输入信息元素的区域。

    作用: 表单用于收集不同类型的用户输入。

    方法: <form></form>定义。

  

二: 实例

1. 文本域(Text field) <input type = "text" name = "username">

2. 密码域(Password field)<input type = "password" name = "password">

三: 输入类型

    1. 文本域 (text fields)

        input type = "text"

    2. 密码域(passwd fields)

        input type = "password"

    3. 单选按钮 (radio buttons)

       input type = "radio" name = "sex"  value = "male"

    4. 复选框(checkbox)

       input type = "checkbox" name = "bike"

    5. 下拉框 (select)

        <form>

        <select name = "cars">

            <option value = "..">Audi</option>

        </select>

        </form>

    6. 带有预选值的下拉框

        <option value = "audi" selected = "selected">Audi</option>

    7. 创建按钮

        <input type = "button" value = "Hello world!">

    8. Fieldset around data

        <form>

            <fieldset>

               <legend></legend>

            </fieldset>

        </form>

四: 表单动作属性(action)和确认按钮

     1. 表单的动作属性定义了目的文件的文件名。

         <form name = "input" action = "html_form_action.asp" method = "get">

        ....

        <input type = "submit" value = "submit">

         </form>

    2.