RE: [PHP-WIN] checkboxes in php
| From: | Charles P. Killmer | Date: | Thu, 10 Jul 2003 14:12:21 +0000 |
| Subject: | RE: [PHP-WIN] checkboxes in php | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-20764@lists.php.net to get a copy of this message | ||
Try this
<?
$i = 0;
echo '<form>';
echo '<input type="checkbox" name="temp['.$i++.']"
value="3124">';
echo '<input type="checkbox" name="temp['.$i++.']"
value="6345">';
echo '<input type="checkbox" name="temp['.$i++.']"
value="456243">';
echo '<input type="checkbox" name="temp['.$i++.']"
value="45">';
echo '<input type="checkbox" name="temp['.$i++.']"
value="6756">';
echo '<input type="checkbox" name="temp['.$i++.']"
value="4567">';
echo '<input type="submit" name="submit"
value="test">';
echo '</form>';
//Then in PHP whether the box is checked or not your indexes are
correct.
print_r($temp);
?>
Charles Killmer
Netgain Technology
-----Original Message-----
From: Luis Moreira [mailto:lamoreira@bes.pt]
Sent: Thursday, July 10, 2003 8:38 AM
To: Harpreet
Cc: php-windows@lists.php.net
Subject: Re: [PHP-WIN] checkboxes in php
Take this for an example :
This script fills part of a form with checkboxes named C1,C2, ect
$cnt=0;
for ($i=1;$i<=$n_alunos;$i++) {
if ($cnt==0) {
print "<tr>";
}
print "<td><input type=\"checkbox\" name=\"C$i\"
value=\"on\">Aluno
$i</td>";
$cnt++;
if ($cnt==$colunas) {
print "</tr>";
$cnt=0;
}
}
This script receives the result from the previous form, and checks
wether checkbox C2 is set or not
if (!empty($_POST['C2'])) {
$b = $_POST['C2'];
}
else {
$b = "vazio";
}
An example ...
----- Original Message -----
From: "Harpreet" <harpreet@crispincorp.com>
To: <php-windows@lists.php.net>
Sent: Thursday, July 10, 2003 2:12 PM
Subject: [PHP-WIN] checkboxes in php
> I have 4 checkboxes in a form. I can select any number of boxes.When i
> go
to
> the results page it gives me errors for boxes i dont select
> Notice: Undefined index: toall in e:\INetPub... on line 27
>
> Please help
> Regards,
> Harpreet
>
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php