dongmei8071 2018-08-14 12:33
浏览 49

如何处理来自其他表单的复选框数据

I am trying to post checkbox values when I click the image in another form, but not succeed. I found a sample and put it inside image POST. When I clicked the image, I want to post coordinates X and Y and checkbox values. I want to avoid submit button. Value $adoor gives error.

Please help me.

//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>
");
    } 
    else 
    {
        echo("<p>You do NOT need wheelchair access.</p>
");
    }

    if(empty($aDoor)) 
    {
        echo("<p>You didn't select any buildings.</p>
");
    } 
    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>

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛