CSC336-WT Lec6 Slides
CSC336-WT Lec6 Slides
• action: Specifies the URL where the form data will be sent.
• method: Defines the HTTP method (GET or POST) used to send data.
• GET: Data is sent via the URL (suitable for small data).
• POST: Data is sent in the request body (for secure, large data).
• Example:
<form action="/submit" method="post">
Form Structure
• The most versatile and commonly used element to collect user input.
• Types: Text, email, password, checkbox, radio, etc.
• Example:
<form>
<input type="text" name="username">
</form>
Common Input Types
Text: Single-line text input. Password: Obscures the Email: Validates the input as Example:
input characters. an email format.
• The name attribute is critical as it identifies the form field when data is submitted
to the server.
• Each input field should have a unique name.
• Example:
<form>
<input type="text" name="username">
</form>
The value Attribute
• When a user submits a form, the browser sends the form data to the server.
• Data is collected and sent based on the input field's name and value attributes.
• Example:
<form action="/submit" method="post">
<input type="text" name="username" value="JohnDoe">
</form>
Form Enhancements with JavaScript
• HTML Forms are fundamental for collecting user input in web applications.
• Forms consist of various elements like <input>, <textarea>, and <button>.
• Understanding form attributes and input elements is key for creating user-friendly
and efficient forms.