Drop Down Menus
Option 1
Option 2
Option 3
Option 4
The drop down menu only allows for the user to select a single answer, and so it can be likened to be a more compact form of a radio button where the options are more visible. Drop down menus are probably easier for your visitors to understand to those new to the internet compared to radio buttons - so I would recommend a drop down menu when you have a lot of options to choose from to reduce the confusion.
The drop down menu is included on a page using the select container tag, with each option being defined with an option tag embedded in the select tag. The name of the data set is defined in the select tag, and the value of the answer is defined separately for each option. If the value is not set for a particular option, then it will default to using the text contained in the opening and closing option tags (or to the text between each option tag if you are not closing them).
<SELECT NAME="choose_one"> <OPTION>Option 1 <OPTION VALUE="Option 2">Option 2 <OPTION VALUE="Option Three">Option 3</OPTION> <OPTION VALUE="They liked the fourth idea!">Option 4</OPTION> </SELECT>
Multi Select Menus
Option 1
Option 2
Option 3
Option 4
Similar to the check box in the way that it works, it only needs a slight modification in the code to make a drop down box that allows for more than one choice to be made. To choose more than one answer, the user will need to hold down the Ctrl key when making their choices.
Below, is the same code we used for the drop down menu example, however we have made the changes needed to allow the user to choose more than one answer. The number of items shown at any one time is defined using the size attribute, but the main difference here is that work multiple is added as an attribute to the select tag.
<SELECT NAME="choose_one" SIZE=3 MULTIPLE > <OPTION>Option 1 <OPTION VALUE="Option 2">Option 2 <OPTION VALUE="Option Three">Option 3</OPTION> <OPTION VALUE="They liked the fourth idea!">Option 4</OPTION> </SELECT>
Hidden Values
Lets just pretend that there is a hidden value on this page right here (there isn't really because even if there was you wouldn't see it, so we didn't need to have one to demonstrate what it looks like). Hidden values can be very useful when you want to pass the same information to the script all the time without having the user write it in. Basically all they do is send a name value pair such that the value is associated with the name when the script reads the input. While you could have a text box for your value and set your value that way, the user may edit the details - which you may not want them to be able to do.
Say for example you have a feedback form on your site, but the script you are using expects you to send along your email address with the details each time you use it. This is one of those occasions where you don't want the user to edit your email address and send someone else a message from your site - so hidden fields are ideal for this kind of information.
<INPUT TYPE="hidden" NAME="recipient" VALUE="rosie@tiggys.co.uk"> <INPUT TYPE="hidden" NAME="subject" VALUE="My Feedback Form">
Buttons
What good is a form if you don't at least have a button to send it? Well... actually that depends as some of the more up to date browsers now submit the form details when you press the enter key in a normal text box. Anyway, in the old days of HTML, you needed a button to do that, and there are 3 different kinds of button available. Plain old buttons (that do nothing when you press them), submit buttons that send off the information for processing, and the reset button for those that make a mistake and want to start all over again.
You can see the reset and submit buttons at work, have a play about with the form and then press reset - the form will revert back to how it was when it was first loaded. Pressing submit will bring you back to this same page, but you will be able to see all of the information that would have been sent to a script by taking a look at the URL in the browser address bar.
Pressing the dummy button however will not do anything, as it is just a button. This may seem like a pretty useless thing to do, but the plain old button has its uses. You may want to add a help button to your form, in which case you can use it to call a JavaScript function that opens up a new window with the help page or of course you may want to show an example of a form but don't want people to use it as it is for demo purposes.
<INPUT TYPE="button" NAME="my_button" VALUE="Dummy Button"> <INPUT TYPE="submit"> <INPUT TYPE="submit" VALUE="Send my Form NOW!"> <INPUT TYPE="reset"> <INPUT TYPE="reset" VALUE="Start Over!">