我有一个包含多列的表,其中一列是复选框.每当选中它时,它会在表格的右侧显示另一个列单元格,并使用向上/向下微调器来设置值.
我遇到的问题是我不能让微调器超过我所拥有的数量列中的数字.所以我需要将相应行中Quantity列的当前值拉入javascript变量,并将其与我的微调器函数一起使用.我已经能够使用值,getElementById但只获取表中的第一个值,并且不适用于表中的任何其他值.我一直在努力,getElementsByClassName但没有运气.
我怎么能成功地做到这一点?
PHP/HTML:
<table id="merchTable" cellspacing="5" class="sortable">
<thead>
<tr class="ui-widget-header">
<th class="sorttable_nosort"></th>
<th class="sorttable_nosort">Loc</th>
<th class="merchRow">Report Code</th>
<th class="merchRow">SKU</th>
<th class="merchRow">Special ID</th>
<th class="merchRow">Description</th>
<th class="merchRow">Quantity</th>
<th class="sorttable_nosort">Unit</th>
<th style="display: none;" class="num">Quantity #</th>
</tr>
</thead>
<tbody>
<?php foreach ($dbh->query($query) as $row) {?>
<tr>
<td class="ui-widget-content"><input type="checkbox" class="check" name="check"></td>
<td class="loc ui-widget-content" id="loc-<?php echo intval ($row['Loc'])?>"><?php echo $row['Loc'];?></td>
<td class="rp-code ui-widget-content" align="center" id="rp-code-<?php echo intval ($row['Rp-Code'])?>"><?php echo $row['Rp-Code'];?></td>
<td class="sku ui-widget-content" id="sku-<?php echo intval ($row['SKU'])?>"><?php echo …Run Code Online (Sandbox Code Playgroud) 我有一个表格,我可以在其中选中一个复选框,它将记录该行中的所有内容。页面上有一些搜索功能和其他按钮,所以我想使用会话存储来保持所有选中、选中、刷新过程中的复选框,直到页面关闭。我从我发现的一个例子中得到了一些东西,但它似乎没有用。我怎么能解决这个问题?
带有复选框的表格列/行的 HTML:
<td class="ui-widget-content"><input type="checkbox" class="check" name="check" id="checkid"></td>
Run Code Online (Sandbox Code Playgroud)
JavaScript:
$(function(){
var test = sessionStorage.input === 'false'? true: false;
$('input').prop('checked', test || false);
$('input').on('change', function() {
sessionStorage.input = $(this).is(':checked');
console.log($(this).is(':checked'));
});
});
Run Code Online (Sandbox Code Playgroud)