当我单击另一种形式的图像时,我试图发布复选框值,但未成功。我找到了一个示例,并将其放入图像POST中。单击图像时,我要发布X和Y坐标以及复选框值。我想避免提交按钮。 $ adoor值给出错误。
请帮助我。
//this is image, ı am posting mouse click coordinates
$column_1 .= '
<form action="" method="post">
<input type="image"
alt="Finding coordinates of an image" src="data:image/png;base64,' .
$bytess . '" alt="Digg" width=150 height=200 border="0" name="foo"
style="cursor:crosshair;"return false"; /></form>';
$tableHeader='<table width="100%">';
$tableFooter='</table>';
$leftTable=$tableHeader;
$rightTable=$tableHeader;
// I am posting coordinates, also want to checkbox values, but not succeed.
if (isset($_POST['foo_x'])){
$foo_x=$_POST['foo_x'];
$foo_y=$_POST['foo_y'];
echo "X=$foo_x, Y=$foo_y ";
$aDoor = $_POST['formDoor'];
if(isset($_POST['formWheelchair']))
{
echo("<p>You DO need wheelchair access.</p>\n");
}
else
{
echo("<p>You do NOT need wheelchair access.</p>\n");
}
if(empty($aDoor))
{
echo("<p>You didn't select any buildings.</p>\n");
}
else
{
$N = count($aDoor);
echo("<p>You selected $N door(s): ");
for($i=0; $i < $N; $i++)
{
echo($aDoor[$i] . " ");
}
echo("</p>");
}
//Checking whether a particular check box is selected
//See the IsChecked() function below
if(IsChecked('formDoor','A'))
{
echo ' A is checked. ';
}
if(IsChecked('formDoor','B'))
{
echo ' B is checked. ';
}
//and so on
}
echo "<table border='1'>
<tr>
<td valign=top >$column_1</td>
</tr>
</table>";
echo "<tr>";
echo "</table>";
echo "<tr>";
?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"
method="post">
<p>
Which buildings do you want access to?<br/>
<input type="checkbox" name="formDoor[]" value="A" />Acorn Building<br
/>
<input type="checkbox" name="formDoor[]" value="B" />Brown Hall<br />
<input type="checkbox" name="formDoor[]" value="C" />Carnegie Complex<br
/>
<input type="checkbox" name="formDoor[]" value="D" />Drake Commons<br />
<input type="checkbox" name="formDoor[]" value="E" />Elliot House
</p>
<p>
Do you need wheelchair access?
<input type="checkbox" name="formWheelchair" value="Yes" />
</p>
</form>
<p>
<a href='http://www.html-form-guide.com/php-form/php-form-
checkbox.html'>Handling checkbox in a PHP form processor</a>
</p>
</body>