HTML Form Fields - Part 2
1. Radio Button:
- Allows the user to choose only one option.
- All radio buttons must share the same 'name'.
- HTML Code Example:
<form>
<p>Select your gender:</p>
<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
</form>
2. Drop-down Menu:
- Provides a list of options in a small menu.
- The user can select one option.
- HTML Code Example:
<form>
<label for="country">Choose your country:</label><br>
<select id="country" name="country">
<option value="india">India</option>
<option value="usa">USA</option>
<option value="uk">UK</option>
</select>
</form>
3. Submit and Reset Buttons:
- Submit Button: Sends form data to the server.
- Reset Button: Clears the form fields.
- HTML Code Example:
<form action="submit.php" method="post">
<input type="submit" value="Submit Form">
<input type="reset" value="Reset Form">
</form>
4. Full Example:
<form action="submit.php" method="post">
<label for="username">Username:</label><br>
<input type="text" id="username" name="username"><br><br>
<p>Select your gender:</p>
<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other<br><br>
<label for="country">Country:</label><br>
<select name="country" id="country">
<option value="india">India</option>
<option value="usa">USA</option>
<option value="uk">UK</option>
</select><br><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>