我尝试总结选中复选框的值。复选框的值是 BALANCE。当我选中复选框时,结果应显示在金额字段上。提前致谢!
echo "<th>Amount: </th>";
echo "<td colspan=2><input type='text' disabled name='amount' id='amount' onchange='addBalance()'></td>";
echo "<td><input type='submit' name='print' value='PRINT'></td>";
echo "</tr>";
foreach ($data as $value) {
echo '<td><input type="text" readonly name="balance$i" value='.$value["BALANCE"].'></td>';
echo "<td><input type='checkbox' name='checkbox_no[]' id='checkbox_no' value=".$value["BALANCE"]." onkeypress='return isNumber(this)' onchange='addBalance()'></td>";
}
<script>
function addBalance(){
var number=document.getElementByName("checkbox_no[]");
var sample =10;
document.getElementById('amount').value = parseFloat(number);
}
</script>
我只得到第一个复选框。其他的不工作