golivebasics.com home page

Forms, part 2

Page 1 Page 3 Page 4 Page 5
Learn to ...

Now we will add some more fields. (Hover over the links at the top for a 'table of contents' - I'm trying a new-to-me action).

Maybe we want to give people a choice.

First we will do an 'either/or' choice, where they can only pick one option. We'll have a set of three radio buttons, where only one can be chosen. Drag three radio buttons into your form. Highlight the first and look at the inspector.

We type a name for 'Group'. This is to link it into the group of three options. Value is what we want to be told when someone chooses this option. For this first button of the three, we check 'Selected' - this means the first button will be checked by default (click here to see how it looks). In the example form in the popup window, try checking different buttons - you will see you can only choose one.

inspector

When you come to name the other two buttons in the group, 'happy' will be available as a choice in the drop-down. Don't check 'Selected' for the second and third buttons, of course.

Note: It's a good idea to have one choice labelled 'none of the above' and maybe make that the default. You should do this especially if you do have one choice selected by default, or people may be forced to choose something they don't want.
We might want to let people choose one or more options. In that case we need Check Boxes, not Radio Buttons.

Put some in your form and highlight one - the Inspector looks like this.

Give your checkbox a name, and for the value put what you want to be told if someone checks that box. A different name for each check box, these are not grouped like radio buttons.

In this case, the information you receive from the form will look a bit like this:

makeitwork: yes.

You can check 'Selected' for as many as you like. Click here to see how it looks now. You can check and uncheck to your heart's content in the pop window!

Note: I suggest above that you give each check box a different name. This makes perfect sense, and it's easy to see which choice people have made.

However, what you can do instead is give each check box the same name - but different values for each one to differentiate them. Then, put a set of empty square brackets after the name for each one, and the results will be sent as a list.

So, you might ask 'which fruit do you prefer?' and make three check boxes. The names and values would look like this:

name="fruits[]" value="apple"
name="fruits[]" value="orange"
name="fruits[]" value="plum"

- you won't put the quotes in when you are in the inspector, they get put in for you in the code.

Now if people check the first two, the result you get will be:

fruits: apple, orange.

This is neat and tidy as far as the results and confirmation page go, but it also means you can make fruits[] a required field, to make sure people choose something - if that's what you want.

This assumes you are going to be using a form-processing script, not the straight email method (see page 4).

Thanks, Nate!

Page 1 | Page 3 | Page 4 (Make it work) | Page 5
golivebasics.com home page