【发布时间】:2020-08-14 12:32:45
【问题描述】:
我用复选框显示了一个项目列表。我希望用户检查他想要的项目并输入他想要的项目数量。我使用 CSS 隐藏了数量文本框 (txtQty)。我想如果你点击一个Item,就会出现对应的txtQty供你输入你想要的Quantity。 我正在使用 CodeIgniter。所以我已经成功地从 MySQL 中通过 Model 拉取数据到 View 并显示出来,如随附的界面图片所示。我正在使用 Jquery 进行隐藏和显示。 The Interface
我的代码: 2。查看代码 (PHP)
<table class="card1 table table-striped table-bordered table-responsive" style="height: 350px; overflow: scroll">
<thead>
<tr>
<th>SN</th>
<th>Product</th>
<th>Tick</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<?php $i=0; foreach($it as $r): $i++; ?>
<tr>
<td><?php echo $i; ?></td>
<td><?=$r['Item'];?></td>
<td>
<label>
<input type="checkbox" name="item[]" value="<?=$r['Item']?>" id="jj">
</label>
</td>
</td>
<td>
<input type="number" name="qty[]" id="tx" style="display: none" />
<input type="hidden" name="price" value="<?=$r['CostPrice']?>" />
</td>
</tr>
<?php endforeach?>
<tr>
<td colspan="3">
<input type="submit" name="btnub" value="Send Order" class="btn btn-warning card1" />
</td>
</tr>
</tbody>
</table>
3。我的 Jquery 代码。
<script>
$(document).ready(function() {
$('#jj').change(function () {
if (this.checked) {
$('#tx').show();
} else {
$('#tx').hide();
}
});
});
</script>
- 我还想知道现在如何在控制器中仅检索选定的项目和数量
【问题讨论】:
标签: php jquery arrays codeigniter