<script>
var itemsAdded = Array();
function moveNumbers(text) {
var i = itemsAdded.indexOf(text)
if ( i >= 0) {
itemsAdded.splice(i,1);
} else {
itemsAdded.push(text);
}
document.getElementById("result").value=itemsAdded.join(" ");
}
$(function() {
for (i=0;i<10;i++) {
console.log(i);
$("body").append("<input type='checkbox' name='add' value='" + i + "' onclick='moveNumbers(this.value)'/> Checkbox" + i + "<br/>");
}
});
</script>
<textarea id="result" cols="12" rows="6" 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:85%;'alt='$file'>
<br>
$file
</td>";
$x++;
}
}
echo "</tr>";
echo "</table>";
closedir($dir_handle);
?>
大家好,我已经设法弄清楚如何将复选框输入添加到文本框中以列出所选项目。感谢那些在这里帮助我的人(弗雷德和乔)。现在我需要添加另一个文本框来添加选择的总项目数和另一个文本框来添加所有选择的项目的总成本。E.G. Check box checked -> Add to list text box (this bit already works) -> Add total items listed to text box -> Add total cost of all items selected (each image costs say $10 each)
我试过了,但剧本太乱了,我以为我会发布原始的起始剧本。你觉得有太多要问的吗?干杯。