如果选中的复选框具有不同的名称但具有相同的ID,我该如何回显所选复选框的列表。另一个函数需要不同的名称,因此我无法将其更改为相同的名称。
PHP代码
$tiles = $_POST['??'];
if(empty($tiles))
{
echo "";
}
else
{
$N = count($tiles);
echo("Tiles Selected: <br> ");
for($i=0; $i < $N; $i++)
{
echo ("-" . $tiles[$i] . " <br> ");
}
}
HTML代码
<div class='material' id='material1'>
<a class='product'>
<div class='tiles_bg' style='background:url(media/images/tile2.jpg);'>
<input class='select_all' id='tile' type='checkbox' name='1marm[]' value='Verde Guatemala'>
</div>
<p>Verde Guatemala</p>
</a>
<a class='product'>
<div class='tiles_bg' style='background:url(media/images/tile1.jpg);'>
<input class='select_all' id='tile' type='checkbox' name='1marm[]' value='Bianco Carrara'>
</div>
<p>Bianco Carrara</p>
</a>
</div>
<div class='material' id='material2'>
<a class='product'>
<div class='tiles_bg' style='background:url(media/images/tile4.jpg);'>
<input class='select_all' id='tile' type='checkbox' name='2gran[]' value='Nero Assolutio'>
</div>
<p>Nero Assolutio</p>
</a>
</div>
<div class='material' id='material10'>
<a class='product'>
<div class='tiles_bg' style='background:url(media/images/GroheEssence.jpg);'>
<input class='select_all' id='tile' type='checkbox' name='10Kok[]' value='Grohe Essence'>
</div>
<p>Grohe Essence</p>
</a>
</div>