Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

3. Forms

Forms are used to capture input from the user. The input of a form is usually receive by a server side program which will receive the input from the form and can then process the data. In the <input> tag you define via the "type" attribute defines the expected type. HTML5 defines lots of possible types, unfortunately currently most of them are not supported by most browsers. If a browser doesn't recognize a certain type it will assume text. So it is save to use the types. Here is a form with some input fields.

				
<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8"> 
  <title>A form</title>
 </head>
 <body>
 <form action="http://vogellatodo.appspot.com/save.php" method="post">
 
 <!-- Simple text field -->
 <label for="text">Name </label> 
 <input type="text" name="input"/>
 <br/>
 
  <!-- Textarea -->
 <label for="textarea">Description </label> 
 <textarea  name="area" cols="50" rows="5">Type your comment here</textarea>
 <br/>
 
 <!-- Two checkboxes -->
 <label for="checkbox1">Linux </label> 
 <input type="checkbox" name="checkbox1" value= "1"/>
 <br/>
  
 <label for="checkbox2">Windows </label> 
 <input type="checkbox" name="checkbox2" value= "2" checked="checked"/>
 <br/>
 
 <!-- Radiobutton -->
 <label for="r1"> Linux </label> 
 <input type="radio" name="radio" value= "r1"/>
 <br/>
  
 <label for="r2">Windows </label> 
 <input type="radio" name="radio" value= "r2" checked="checked"/>
 <br/>
 
  <!-- Select Options -->
 <select name="Browser">
 <option selected="selected"> Firefox </option>
 <option> Internet Explorer</option>
 <option>Chrome </option>
 </select>
  <br/>	
 
 
 <input type="submit" name="submit" value="Send Request"/>
 </form>
 </body>
</html>