JAVAEE take a closer look at JavaWeb 08-form tags

form tag

HTML tags: form tags
form:
concept: used to collect user input data. Used to interact with the server.
form: used to define the form. A range can be defined, and the range represents the range of collecting user data.
Attribute:
action: specify the URL of the submitted data
method: specify the submission method
Category: a
total of 7 types, 2 types are commonly used
get:

  1. The request parameters will be displayed in the address bar. Will be encapsulated in the request line
  2. The request parameter size is limited.
  3. Not very safe.
    post:
  4. Request parameters are no longer displayed in the address bar. Will be encapsulated in the request body
  5. There is no limit to the size of the request parameters.
  6. Relatively safe.
    If the data in the form item is to be submitted: the name attribute must be specified
<form action="#" method="get">
    用户名:<input type="text" name="username"><br>
    密码:<input type="text" name="password"><br>
    <input type="submit" value="登录">
</form>

Form item label:
input: You can change the style of element display by the value of the type attribute
* type attribute:
* text: text input box, default value
* placeholder: specify the prompt information of the input box, when the content of the input box changes, it will automatically Clear the prompt information
* password: password input box
* radio: radio box
* Note:
1. If you want multiple radio boxes to achieve the effect of radio, the name attribute value of multiple radio boxes must be the same.
2. Generally, each radio button is provided with a value attribute, which specifies the value submitted after being checked.
3. The checked attribute can specify the default value
* checkbox: check box
* Note:
1. Generally, each radio button is given Provide the value attribute to specify the value submitted after being selected
2. The checked attribute can specify the default value
* file: file selection box
* hidden: hidden field, used to submit some information.
* Button:
* submit: Submit button. Can submit form
* button: normal button
* image: image submit button
* src attribute specifies the path of the image

		  * label:指定输入项的文字描述信息
			   * 注意:
				   * label的for属性一般会和 input 的 id属性值 对应。如果对应了,则点击label区域,会让input输入框获取焦点。
<form action="#" method="get">
    <label for="username">用户名:</label><input type="text" name="username" placeholder="请输入用户名" id="username"><br>
    密码:<input type="password" name="password" placeholder="请输入密码"><br>
    性别: <input type="radio" name="gender" value="male" checked>男
    <input type="radio" name="gender" value="female">女<br>
    <br>
    爱好:<input type="checkbox" name="love" value="singing" checked>唱歌
    <input type="checkbox" name="love" value="dancing">跳舞
    <input type="checkbox" name="love" value="erhu" checked>拉二胡
    <input type="checkbox" name="love" value="hiking">徒步旅行
    <br>
    <input type="submit" value="登录">
</form>

select: drop-down list
* child elements: option, specify the list item

省份: <select name="province">
     <option value="">--请选择--</option>
     <option value="1">北京</option>
     <option value="2">上海</option>
     <option value="3" selected>深圳</option>
 </select>

textarea: text field
* cols: specify the number of columns, how many characters are in each row
* rows: the default number of rows.

描述:<textarea name="desc" id="" cols="30" rows="10"></textarea>

Published 78 original articles · praised 30 · visits 3661

Guess you like

Origin blog.csdn.net/ZMW_IOS/article/details/103994242