Form elements include text fields, text area fields, drop-down menus, radio buttons, checkboxes, etc. which are used to take information from the user.
Every form have the structure made of the opening and closing <form> tags which is a container for input controls and processing methods. The form tags surround the entire form, just as html tags surround the entire HTML document. The syntax is as follows
<form action=”back-end script” method=”posting method”>
form elements like input, text area etc.
Other than standard and UI event attributes, <form> tag has other attributes which are
name: This is the name of the form. It is case-sensitive and should be unique.
action: It is used to specify any script URL which will receive uploaded data.
method: It is used to specify method to be used to upload data. It can take various values but most frequently used are GET and POST.
target: It specifies the target page where the result of the script will be displayed. It can be _blank, _self or _parent
enctype: It is used to specify how the browser encodes the data before it sends it to the server. Possible values are like
- application/x-www-form-urlencoded – It s the default method used by most forms. It converts spaces to the plus sign and non-alphanumeric characters into the hexadecimal code for that character in ASCII text.
- mutlipart/form-data – It allows the data to be sent in parts, with each consecutive part corresponding the a form control, in the order they appear in the form. Each part can have an optional content-type header of its own indicating the type of data for that form control.