<form method="[POST|GET]" action="myFilePath" name="myForm">HTML forms are containers that hold various input elements and submit user data to a server for processing. The form element itself defines how and where the data should be sent.
<form action="/tutorials/index.htm">Is equivalent to:
<form action="http://localhost/tutorials/index.htm">
/[RELATIVE_PATH_OF_THE_CURRENT_PAGE]/Then, the resource requested must have the following path on the server :
/[RELATIVE_PATH_OF_THE_CURRENT_PAGE]/myFilePathExample:
<form action="tutorials/index.htm">Is equivalent to:
<form action="http://localhost/[RELATIVE_PATH_OF_THE_CURRENT_PAGE]/tutorials/index.htm">
<input type="text" name="myText1" value="aaa" readonly disabled />Text input controls create single-line text fields for user input. They are the most common form elements and support various attributes for customization:
<input type="password" name="myPassword1" value="bbb" />Password input controls are similar to text inputs but mask the entered characters for security purposes. The characters are typically displayed as dots or asterisks to prevent shoulder surfing.
<input type="hidden" name="myHidden1" value="ccc" />Hidden input controls store data that needs to be submitted with the form but should not be visible or editable by the user. They are commonly used for:
<textarea name="myTextarea1" rows="5" cols="35"> ... </textarea>Textarea controls provide multi-line text input areas, ideal for longer content such as comments, descriptions, or messages. Unlike input elements, textarea uses opening and closing tags with the default content placed between them.
<input type="radio" name="myRadio1" value="0" checked /> <input type="radio" name="myRadio1" value="1" />Radio buttons allow users to select exactly one option from a group of mutually exclusive choices. They are ideal for questions where only one answer is permitted.
<input type="checkbox" name="myCheckbox1" value="0" checked disabled /> <input type="checkbox" name="myCheckbox1" value="1" />Checkbox controls allow users to select zero, one, or multiple options from a set of choices. Unlike radio buttons, checkboxes operate independently and multiple selections are permitted.
myCheckbox1=0&myCheckbox1=1This demonstrates how multiple values with the same name are transmitted when multiple checkboxes in a group are selected.
<select name="mySelect1"> <option value="A">V1</option> <option value="B" selected>V2</option> <option value="C">V3</option> </select>Single-selection dropdown controls (select elements) provide a compact way to offer multiple choices while saving screen space. They display one option at a time and expand to show all available options when clicked.
mySelect1=BThe value attribute of the selected option is what gets transmitted, not the display text.
<select name="mySelect2" multiple> <option value="A" selected>V1</option> <option value="B">V2</option> <option value="C" selected>V3</option> </select>Multiple-selection dropdown controls allow users to select several options simultaneously. The "multiple" attribute transforms the select element's behavior and appearance.
mySelect2=A&mySelect2=CEach selected option generates a separate name-value pair in the form submission, similar to how multiple checkboxes with the same name behave.
<input type="button" name="myButton1" value="button" onclick="call_js_function();" />Button controls create clickable buttons that perform custom actions through JavaScript. Unlike submit or reset buttons, regular buttons have no default behavior and require JavaScript event handlers to function.
<input type="submit" name="mySubmit1" value="submit" />Submit button controls trigger form submission when clicked. They are essential for sending form data to the server for processing. When activated, they cause the browser to collect all form data and send it to the URL specified in the form's action attribute.
<input type="reset" name="myReset1" value="reset" />Reset button controls restore all form elements to their initial default values when clicked. This provides users with a quick way to clear their input and start over without manually clearing each field.