Posted by T. Wintershoven on 11/04/06 15:11
Hello all,
I have a form with some checkboxes.
The names of these checkboxes come from an array.
When i click the submit button the resultcode doesn't recognize the names
when i want to check wether or not some checkboxes are ticked.
Assume that i tick checkboxes 100, 150 and 200
Below is some code i've used.(between the ****** lines)
************************************************
if (!isSet($_POST['submit']))
{
ShowForm();
}
else
{
HandleForm();
}
function ShowForm()
{
//normally, these values come out of a database
$question=array();
$question[0]="100";
$question[1]="125";
$question[2]="150";
$question[3]="175";
$question[4]="200";
echo"<form name='form1' method='post' action='".$_SERVER['PHP_SELF']."'>";
for($i=0; $i<5; $i++)
{
echo "<input type='checkbox' name=$question[$i]> This is the
question with ID ". $question[$i]."<br/>";
}
echo "<BR><input type='submit' name='submit' value='Show choice'>";
echo"</form>";
}
function HandleForm()
{
for($i=0; $i<5; $i++)
{
if(isset($_POST[$question[$i]]))
{
echo "Question ".$_POST[$question[$i]]." was
ticked.<br/>";
}
}
}
********************************************************
Function HandleForm doesn't recognize $_POST[question[$i]]
Can anyone help me solve this problem.
T.i.a.
Regards
Tino Wintershoven
The Netherlands
Navigation:
[Reply to this message]
|