Forms in html - How to get the User information??

 Forms are the interesting feature of HTML. This gets input from the user and sends it to the server for processing.

Tag used : <form>

It has many elements

  • ·       <input>
  • ·       <label>
  • ·       <select>
  • ·       <textarea>
  • ·       <button>
  • ·       <fieldset>
  • ·       <legend>
  • ·       <datalist>
  • ·       <output>
  • ·       <option>
  • ·       <optgroup>

A sample coding  is explained as follows. This form gets the firstname and lastname of a user,gender and email id. This form gets the user  details and click the submit button.

Example: Form to get the details of a user

<html>

<head> <title> Enquiry form </title></head>

<body>

<form>

<label for=”Firstname”>Firstname :</label>

<input type=”text” id=”firstname” name=”firstname”><br>

<label for=”Lastname”> Lastname:</label>

<input type=”text” id=”Lastname” name=”Lastname”><br>

<label for=”gender”> Choose the gender:</label>

<input  type=”radio” name=”gender” id=”gender” value=”female”>

<input  type=”radio” name=”gender” id=”gender” value=”male”>

<input  type=”radio” name=”gender” id=”gender” value=”others”><br>

<label for=“email”>Enter the email :</label>

<input type= “email” id=”email” name=”email”><br>

<input type=” Submit” value=”Submit”>

</form>

</body>

</html>


The ouput will be

Enquiry form

Firstname:

Lastname:

Choose the gender: female    male    others

Enter the email:

Submit


This is the basic form to get the user details. Form has variety of usage when it used with scripting languages.

No comments:

Post a Comment