HTML Forms
What is the form?
The form is used to take values or data from the user and to send the data for storage in the database.
Text:
1 2 3 4 5 6 7 8 | <html> <body><form> 1st name<input type="text" name="1stname" value="hamza"> <br> Second name<input type="text" name="secondname" value="dsfsd"> <br> <input type="submit" value="Submit"> </form></body></html> |
Output:
You can also apply input type as “password”. If you write it as follows;
<input type=”password” >
it will create the text box but all typed values are hidden and does not appears on the screen. Instead stars * are appears on the screen.
Radio Button:
<html> <body><form> <input type=”radio” value=”male” name=”gender” > Male<br> <input type=”radio” value=”female” name=”gender” checked> Female<br> </form></body> </html> |
Output:
Text Area:
A larger text area can also be defined to get a large message
<html> <body><form> <textarea name=”message” cols=”10″ rows=”5″ >Welcome to T4Tutorials.com</textarea> <br> <input type=”submit”> </form></body> </html> |
Output:
Select and Option
1 2 3 4 5 6 7 | <label for="Fruites">Choose a car:</label> <select> <option value="Banana">Banana</option> <option value="Apple">Apple</option> <option value="Orange">Orange</option> <option value="Strawberry" selected>Strawberry</option> </select> |
Output