<script language="javascript" type="text/javascript">
function moveNumbers(num) {
var txt=document.getElementById("result").value;
txt=txt + num;
document.getElementById("result").value=txt;
}
</script>
<textarea id="result" name="image_id" rows="8" cols="11" readonly>
</textarea>
<tr>
<?php
$path = "photos/";
$dir_handle = @opendir($path) or die("Unable to open folder");
echo "<table height='500px'width='800px'align='center'border='1'>";
echo "<tr>";
while (false !== ($file = readdir($dir_handle))) {
if($file == "index.php")
continue;
if($file == ".")
continue;
if($file == "..")
continue;
{
echo ($x % 6 == 0) ? "</tr><tr>" : "";
echo "<td><input type='checkbox' name='add' value='$file'
onclick='moveNumbers(this.value)'>
<img src='photos/$file'alt='$file' style='height:auto;width:50%;'alt='$file'>
<br>
$file
</td>";
$x++;
}
}
echo "</tr>";
echo "</table>";
closedir($dir_handle);
?>
大家好,PHP 查找图像文件并在它们旁边显示复选框。我在输入文本区域的复选框时遇到问题。选中它会添加文本,然后当您取消选中它会再次添加相同的文本。我正在尝试执行以下操作:选中 -> 添加文本,取消选中相同的复选框 -> 删除文本。有任何想法吗?