Home » Categories » Multiple Categories

How do I use drop down menus, checkboxes or radio buttons in forms?

You can use any input type in registration and modify profile forms. Nothing special is needed as long as you use the correct field name (custom1 custom2 etc for registration forms and newcustom1 newcustom2 etc for modify profile forms) and make sure the field is allowed in the form (in the YNYY setting). This is just the same as using a normal text input. So for example the following would work in a registration form.

<input type="checkbox" name="custom1" value="Agreed">

The only thing that is also useful is to redisplay a setting already entered in case the form returns an error for example. We can use some simple PHP for that (the bit in bold).

Drop down menu

<select name="custom1">
<option value="Male" <?php if ($custom1=="Male") echo "selected"; ?> >Male</option>
<option value="Female" <?php if ($custom1=="Female") echo "selected"; ?> >Female</option>
</select>

Checkbox

<input type="checkbox" name="custom1" value="Agreed" <?php if ($custom1=="Agreed") echo "checked"; ?> >

Radio buttons

<input type="radio" name="custom1" value="Yes" <?php if ($custom1=="Yes") echo "checked"; ?> >
<input type="radio" name="custom1" value="No" <?php if ($custom1=="No") echo "checked"; ?> >
Attachments Attachments
There are no attachments for this article.