Task 4: Building a Multi-Input Form in HTML
Action Plan: "Start by breaking down your seemingly impossible goal into smaller, actionable tasks. Create a detailed plan outlining the steps required to achieve your goal. Identify any potential obstacles or challenges and brainstorm solutions to overcome them."
Affirmations: "I am committed to making the impossible possible and finishing my work. I am capable of overcoming any challenges that come my way. With persistence and determination, I will achieve success."
Task Answer - Video Linkβ
πΉ If you donβt understand the task, watch the video above for the answer.
Taskβ
Step 1: Install Gitβ
"Our form will include:" β Username field β A text box for users to enter their name. β Password field β A hidden input field for secure entry. β Comment box β A multi-line text area where users can write feedback. β Radio buttons β To let users select their favorite programming language. β Submit button β To send the form data when completed.
Step 2: Writing the HTML Codeβ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multi-Input Form</title>
</head>
<body>
<div>
<h1>Multi-Input Form</h1>
<form action="http://www.enochgeorge.com/submit.php" method="POST">
<label for="username">Username:</label>
<input type="text" id="username" name="username" placeholder="Enter your username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Enter your password" required>
<label for="comments">Your Comments:</label>
<textarea id="comments" name="comments" rows="4" placeholder="Enter your comments..." required></textarea>
<p><strong>Favorite Programming Language:</strong></p>
<input type="radio" id="java" name="language" value="java" checked>
<label for="java">Java</label>
<input type="radio" id="javascript" name="language" value="javascript">
<label for="javascript">JavaScript</label>
<input type="radio" id="python" name="language" value="python">
<label for="python">Python</label>
<button type="submit">Submit</button>
</form>
</div>
</body>
</html>
"Letβs start by creating our HTML file."
1οΈβ£ Open your code editor (VS Code, Notepad++, etc.) 2οΈβ£ Create a new file called form.html 3οΈβ£ Type the following code:
<form> element β Defines the form and its action (where data is sent).
<label> elements β Provide descriptions for the input fields.
<input type="text"> β A field where users can type their username.
<input type="password"> β A secure field where text is hidden.
<textarea> β A text box for users to write multiple lines.
Radio buttons β Users can pick their favorite programming language.
Step 3: Adding Radio Buttons for Selectionβ
<input type="radio" id="python" name="language" value="python" checked>
<label for="python">Python</label>
<input type="radio" id="javascript" name="language" value="javascript">
<label for="javascript">JavaScript</label>
<input type="radio" id="java" name="language" value="java">
<label for="java">Java</label>
Step 4: Adding a Submit Buttonβ
<button type="submit">Submit</button>
Step 4: Adding a Submit Buttonβ
Step 5: Testing the Form
- Save the file as form.html
- Open it in a browser
- Fill out the form with test data
- Click the Submit button