HTML Form
HTML?
- a markup language, a set of markup tags
- well-form: < & >, <> & </>
- uses markup tags to describe web pages
- HTML Structure = <!DOCTYPE html> + <head>…</head> + <body>…</body>
- HTML Documents = Web Pages
- describe web pages
- contain HTML tags and plain text
- are also called web pages
- a markup language, a set of markup tags
HTML Form:
- on the client-side for inputting information to transfer to the server through requests
- a user's interface control that serves as the point of connection between the user and the server.
parameters :
- <name,value> pairs
- string type
- are transferred from the client —request—> server.
- If not exist for a name —> get null in the server when trying to get value.
- If have duplicated name —> server gen a corresponding array has the same name and contains unknown order for corresponding values.
- Note*: default value for each parameter without setting is an empty string.
Fields/Controls in HTML Form: 💡Fields/controls in the form —convert—> parameters
Input tag
type=”text”
- The size attribute: width of text field in characters\
- The maxlength attribute: the maximum number of characters that a user can type.
into the text field
- type=”password”
- A browser should mask the character
- type=”hidden”
- The hidden field is not shown to the user, but the data is sent when the form is submitted.
- type=”checkbox”:
- checked=“checked” sets up the checkbox as already selected
- Một khi checkbox không được check → parameter tương ứng không tồn tại và gửi về server)
- type=”radio”
- The choice made is mutual exclusive
- The name attribute is crucial to tying together a group of radio buttons
- type=”submit”
- value = label
- nếu không có value thì sẽ được set giá trị phụ thuộc vào browser. → cần set giá trị cho một input submit
- reset:
- ko gửi j, chỉ yêu cầu browser xóa trắng dữ liệu của form
- button (custom):
- which is connected to some soft of script
💡Notice:
- nếu value của một control/field ko tồn tại —> lấy content làm value
- Control dạng radio/checkbox luôn phải set giá trị default
- Select:
- giá trị default tự động luôn chọn thằng option đầu tiên
- reset, button: không là parameters
- Khi đặt câu hỏi, cần hỏi phía nào: client / server?
Lỗi thường gặp với form:
- Server ko nhận được dữ liệu:
- Ko có form
- Fileds/Controls bị đặt ngoài form
- Sai URL for action






