|
Posted by Pedro Graca on 10/30/06 17:17
Bob Sanderson wrote:
> I have a form which uses several radio buttons to enter data. It works fine
> as far as entering goes, but I can't figure out how to display which button
> is checked when I view the record. I could do a if-then routine but it
> seems like there should be an easier way.
>
> Any help will be greatly appreciated.
What's your HTML like and how are you dealing with it in PHP?
This (with possible unintended errors corrected) works:
<!-- HTML, assume correct DOCTYPE, ... -->
<form ...>
<div class="group1">
<label><input type="radio" name="r[0]" value="0" checked>none</label>
<label><input type="radio" name="r[0]" value="1">one</label>
<label><input type="radio" name="r[0]" value="1">two</label>
</div>
<div class="group2">
<label><input type="radio" name="r[1]" value="0" checked>none</label>
<label><input type="radio" name="r[1]" value="1">one</label>
<label><input type="radio" name="r[1]" value="1">two</label>
</div>
<!-- some submit button -->
</form>
And the PHP that deals with it could be
<?php
foreach ($_POST['r'] as $k=>$radio) {
echo 'For group ', $k, ', you selected the option with ',
$radio, " for its value.<br>\n";
}
?>
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Navigation:
[Reply to this message]
|