HTML Forms

Action Method and Name Properties

When we created a form we used code similar to the following:

Option Buttons and Select Elements

Option buttons and Select elements ( drop down boxes) are slightly different in that they can supply different values as the user does not type anything.

Select Example

The code below creates a drop down box with all of the months listed in it. 

The user would be presented with this control with the options as shown below.

You will notice that the value and the text displayed can be different.

The value selected would be accessed using the following PHP code:

$month = $_POST['month'] ; 

Option/Radio Buttons

Again with radio buttons the user does not enter any value, they select an option. The code below would provide the user with 3 radio butons to choose from:

You will notice that each of the radio buttons has the same name. And again the value property and the text displayed to the user do not have to be identical

This would render as the screenshot above.