Gary White wrote:
> On Wed, 28 Nov 2007 13:29:34 +0000, David Powers
<david@example.com>
> wrote:
>
>
>>if ($_POST) {
>> $yes = 0;
>> for ($i = 1; $i <= 100; $i++) {
>> if (isset($_POST['q'.$i]) && $_POST['q'.$i]
== "yes") {
>> $yes += 1;
>> }
>> }
>>}
>>
>>$yes contains the number of "yes" answers. 100 - $yes
is the number of
>>"no" answers.
>
>
> Not necessarily. If there are any unanswered questions,
there may be
> less "no" answers. I'd suggest:
>
> if ($_POST) {
> $yes = 0;
> $no = 0;
> for ($i = 1; $i <= 100; $i++) {
> if (isset($_POST['q'.$i])) {
> if ($_POST['q'.$i] == "yes") {
> $yes ++;
> } else {
> $no ++;
> }
> }
> }
> }
>
> Now, $yes contains the number of "yes" answers, $no
contains the number
> of "no" answers. The number of questions answered is the
sum of $yes and
> $no.
>
> Gary
http://www.w3.org/TR/html401/interact/forms.html#radio
If no radio button in a set sharing the same control name is
initially
"on", user agent behavior for choosing which control is
initially "on"
is undefined. Note. Since existing implementations handle
this case
differently, the current specification differs from RFC 1866
([RFC1866]
section 8.1.2.4), which states:
At all times, exactly one of the radio buttons in a set is
checked. If
none of the <INPUT> elements of a set of radio buttons
specifies
`CHECKED', then the user agent must check the first radio
button of the
set initially.
Since user agent behavior differs, authors should ensure that
in each
set of radio buttons that one is initially "on".
Mick