There's probably an easy solution to this and I'm just overthinking it, but I have a form where there's a series of radio buttons, one of which is "Other". If the user clicks "Other" they should be required to enter something in the text field.
Does anyone know how to concatenate the input from the two fields and store them in the database? Is there an easier way? I was thinking if a user clicks "Other" and types in "Milk", then "Other:Milk" is what is actually stored in the database. Must be simpler way?
I tried this:
<!-- The HTML code for this particular question -->
<p><li>What's your favorite color?
<p>
<dt><input type="radio" name="gd_set_1B" value="Red">Red<br />
<dt><input type="radio" name="gd_set_1B" value="Blue">Blue<br />
<dt><input type="radio" name="gd_set_1B" value="Other">Other:
<input type="text" name="gd_set_1B_Other"
if ($_POST['gd_set_1B'] == 'Other') {
if (!empty($_POST['gd_set_1B_Other'])) {
$GD1B = escape_data($_POST['gd_set_1B_Other']);
} else {
$GD1B = FALSE;
echo '<p>ENTER IT';
}
} elseif ($_POST['gd_set_1B'] != 'Other') {
$GD1B = escape_data($_POST['gd_set_1B']);
} else {
$GD1B = '';
}