Forum Moderators: coopster
<label for "rating">*Service Rating:</label>
<input type="radio" name="rating" value="1" /> 1-Unsatisfactory
<input type="radio" name="rating" value="2" /> 2-Below Average
<input type="radio" name="rating" value="3" /> 3-Satisfactory
<input type="radio" name="rating" value="4" /> 4-Good
<input type="radio" name="rating" value="5" /> 5-Excellent</label> value="<?php echo $_POST['email']; ?>"
function get_svc_radios() {
$radios="<strong>*Service Rating:</strong>";
$ratings = Array(
1 => '1-Unsatisfactory',
2 => '2-Below Average',
3 => '3-Satisfactory',
4 => '4-Good',
5 => '5-Excellent',
);
foreach ($ratings as $key => $value) {
// Note the *proper* application of labels here, assigned to ID
$id = 'rating_' . $key;
$radios .= "<input type=\"radio\" name=\"rating\" id=\"$id\" value=\"$key\"";
if (isset($_POST['rating']) and ($_POST['rating']==$key)) { $radios .= ' checked'; }
$radios .= "> <label for=\"$id\">$value</label>";
// Or ' checked="checked" if you *really need* a valid XHTML doctype.
// Which most people don't.
}
return $radios;
}
[edited by: rocknbil at 6:34 pm (utc) on Feb 18, 2011]