gpt4 book ai didi

javascript - 检查引导表行 - Javascript

转载 作者:行者123 更新时间:2023-12-03 10:51:07 24 4
gpt4 key购买 nike

我需要根据数据库中存储的值选中/取消选中表复选框。我不是一个经验丰富的程序员。我已经用谷歌搜索了一整天,但没有运气。希望有人能帮助我。

代码如下:

echo "<table data-toggle='table' data-click-to-select='true' id='potable'>";
echo "<thead>";
echo "<tr>";
echo "<th data-field='state' data-checkbox='true'></th>";
echo "<th data-field='code'>Code</th>";
echo "<th data-field='description'>Description</th>";
echo "<th data-field='verb'>Verb</th>";
echo "<th>Actions</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
extract($row);
echo "<tr>";
echo "<td>"; ?>
<script>
var select = <?php echo "{$selected}"; ?>;
if (select == 1) {
// INSERT HERE JAVASCRIPT LINE THAT CHECKS THE CURRENT CHECKBOX
else {
//UNCHECK THE CURRENT CHECKBOX
}
</script>
<?php
echo "</td>";
echo "<td>{$code}</td>";
echo "<td>{$description}</td>";
echo "<td>{$verb}</td>";
echo "<a type='button' class='btn btn-primary left-margin' href='po-info.php?id={$id}'>Info</a>";
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";

最佳答案

终于成功了使用过

echo "<th data-field='selected' data-checkbox='true' data-formatter='stateFormatter'></th>";

然后

<script>
function stateFormatter(value, row, index) {
if (value == 1) {
return {
checked: true
};
} else {
return {
checked: false
};
}
return value;
}
</script>

关于javascript - 检查引导表行 - Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28415465/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com