我有几个小时的工作表页面,它被添加到一个数组中以放入数据库。我现在有复选框传递以显示复选框,但我需要将复选框设置为数据库以便下次读取。 (感谢另一位论坛用户)
我尝试使用Value =“1”,但即使检查了它也会传递该值。
因此,如果选中“add_overtime_hours”,则需要在字段中输入1而不检查= 0
<!-- this next section is to dynamically add the parts fields to the jobsheet page so more parts can be added on the page without it starting out too large. -->
<!-- this ext section is the Adding Hours on the jobsheet -->
var rownumhours = 0;
function addhours(obj, e) {
rownumhours++;
var hoursrow = '<p id="rownumhours' + rownumhours + '">Start Time: <input type="time" name="add_start[' + rownumhours + ']" size="4" value="' +
$(obj).closest('span.headings').find('[name="add_start"]').val() + '"> Finish Time: <input type="time" name="add_finish[' + rownumhours + ']" value="' +
$(obj).closest('span.headings').find('[name="add_finish"]').val() + '"> Date: <input type="date" name="add_date[' + rownumhours + ']" value="' +
$(obj).closest('span.headings').find('[name="add_date"]').val() + '"> Overtime: <input type="checkbox" name="add_overtime_hours[' + rownumhours + ']" size="1" value="' +
$(obj).closest('span.headings').find('[name="add_overtime_hours"]').val() + '"' +
(($(obj).closest('span.headings').find('[name="add_overtime_hours"]').is(':checked')) ? 'checked' : '1') + ' "> Show Ovt: <input type="text" name="show_overtime_hours[' + rownumhours + ']" value="' +
$(obj).closest('span.headings').find('[name="add_overtime_hours"]').val() + '"> <input type="button" value="Remove" onclick="removeRow(' + rownumhours + ');"></p>';
jQuery('#hoursrow').append(hoursrow);
}
function removeRow(rnum) {
jQuery('#rownumhours' + rnum).remove();
}
<td colspan="3" align="left"><div id="hoursrow">
<p>
<span class="text">
Hours Labour :
</span>
</span>
</p>
<p>
<span class="headings">
<span class="text">
<span class="hours">
Start Time: <input type="time" name="add_start" size="4" />
Finish Time: <input type="time" name="add_finish" size="4" />
Date: <input type="date" name="add_date" size="4" />
OVT: <input type="checkbox" name="add_overtime_hours" id="add_overtime_hours" value="" size="1" maxlength="1" />
</span>
</span>
<span class="text">
<span class="hours">
<input onclick="addhours(this, event);" type="button" value="Add Labour" />
</span>
</span>
</p>
我不确定从哪里开始
谢谢你的帮助