HTML

UNIT 9 FORMS



Back to the index| Previous | Next

Competences: To insert a form in the web page

Contents: Different kinds of input

What are HTML Forms?

Look at the forms for different kinds of input:

What's your name? (this is an input type text)

Write here a secret word (this is an input type password)

Are you male or female ? (this is an input type radio: you can select only one)

What do you like?
sport computer cooking animals (these are inputs type checkbox: you can select more)

Push the button to send the information (this is an input type submit that sends all the information, stored in variables, to a file that can modify them).

Our HTML pages aren't interactive ones, so we must learn something else about programming language to use these forms! Perhaps the next year??

The code of some Form

CodeOutputSome examples in the w3schools site
This is an input type text <input type="text" /> This is an input type text Input type text
This is an input type radio <input type="radio" /> This is an input type radio Input type radio
This is an input type checkbox <input type="checkbox" /> This is an input type checkbox Input type checkbox
This is a select menu <select>
<option>A</option>
<option>B</option>
</select>
This is a select menu Select
This is an input type submit <input type="submit" /> This is an input type submit Type text and submit
Type radio and submit
Type checkbox and submit

Interact with a PHP page!

  • Open your file index.htm (or page2.htm, or page3.htm ...) and insert a form in it in this way:
    <html>
    <body>
    ........... 
     
     <form action="http://www.openfisica.com/lezioni_html/inglese/calcola.php" method="post">
     Insert two numbers: 
     <input type="text" name="a" /> 
     <input type="text" name="b" />
     <input type="submit" />
     </form> 
     ..........
    </body>
    </html>
    
  • Pay attention! In the form tag, the action attribute sends the data to the file calcola.php.
  • You have to put the names (a and b) of the variables in the input tags.
  • Save the file in your local site and test it.
  • Upload the file in the remote site and test it.
  • Write a message in the forum "Forms" to inform that your page is ready!

  • Ludovica Battista

    Back to index| Previous | Next