我想知道我的代码中是否有一种方法可以让用户单击图像,但在单击时获取图像的值并通过发布请求发送到 PHP 代码。例如目前我有这个:
<div class="grid-2 dashboardIcons">
<h3 class="fontAmaticH1">Mindfulness</h3>
<a class="cursor" onclick="toggleWindow()"><img value="6" src="images/Mindfulness.png"></a>
</div>
我是否必须将其包装在如下所示的表单标签中?
<form method="post">
<a class="cursor" onclick="toggleWindow()"><img value="6" name="module" src="images/Mindfulness.png"></a>
</form>
然后,我的 PHP 代码将采用该值并对其进行处理:
<?php
// I need to get the value from the clicking on an image
if(isset($_POST['module']))
{
//Do something
}
?>
任何帮助将不胜感激!
智慧大石
富国沪深