HTML Forms
CheckBox Control
CheckBox Control
The checkbox control is used to check multiple options from given checkboxes.
Example
<form> Hobby:<br> <input type="checkbox" id="cricket" name="cricket" value="cricket"/> <label for="cricket">Cricket</label> <br> <input type="checkbox" id="football" name="football" value="football"/> <label for="football">Football</label> <br> <input type="checkbox" id="hockey" name="hockey" value="hockey"/> <label for="hockey">Hockey</label> </form>
Output
File Upload Box
File Upload Box Control
Specifies what file types the user can pick from the file input dialog box: It is created using input element with attribute type file
Example
<form> <input type = "file" name = "fileupload" accept = "image/*" /> </form>
Output
HTML Forms
HTML Forms
An HTML form is a section of a document which contains controls such as text fields, password fields, checkboxes, radio buttons, submit button, menus etc. An HTML form facilitates the user to enter data that is to be sent to the server for processing such as name, email address, password, phone number, etc. HTML forms are required if you want to collect some data from of the site visitor. For example: If a user want to purchase some items on internet, he/she must fill the form such as shipping address and credit/debit card details so that item can be sent to the given address.
HTML Form Syntax
We use the <form> tag to create HTML form .The example of it's syntax is :
Example
<from action="server url" method="get|post"//input controls e.g. textfield, textarea,
</form>
radiobutton, button
Form Attributes
Form Atrributes
No. | Attributes and Definition |
---|---|
1. | action: Backend script ready to process your passed data. |
2. | method: Method to be used to upload data. The most frequently used are GET and POST methods. |
3. | target: Specify the target window or frame where the result of the script will be displayed. It takes values like _blank, _self, _parent etc. |
4. | enctype: You can use the enctype attribute to specify how the browser encodes the data before it sends it to the server. Possible values are −. |