jqueryとphpを使用したチェックボックスに問題があります。私は数時間の行を追加していますが、フォーム上のOvertimeチェックボックスを追加したいのですが、jqueryを使用してデータを新しい行に追加して、チェックボックスを追加してください。私のフォームデータは以下の通りです。チェックボックス新しい行を追加するときの動的jquery
チェックボックスをオンにしたい場合はチェックボックスをオンにし、チェックされていない場合は0をチェックします。
フィールドは、私が間違っているのかに付与することができる任意の助けてくれてありがとうadd_overtime_hours
<!-- this ext section is the Adding Hours on the jobsheet -->
<script type="text/javascript">
var rownumhours = 0;
function addhours(frm) {
rownumhours ++;
<!-- the next part creates the html to add dynamic fields into the Div hoursrow
var hoursrow = '<p id="rownumhours'+rownumhours+'">Start Time: <input type="text" name="add_start[]" size="4" value="'+frm.add_start.value+'"> Finish Time: <input type="text" name="add_finish[]" value="'+frm.add_finish.value+'"> Date: <input type="text" name="add_date[]" value="'+frm.add_date.value+'"> Overtime: <input type="checkbox" name="add_overtime_hours[]" size="1" value="'+frm.add_overtime_hours.value+' "> <input type="button" value="Remove" onclick="removeRow('+rownumhours+');"></p>';
<!-- the next part looks at the partsrow div lower in the page and then appends the values to the row variable above -->
jQuery('#hoursrow').append(hoursrow);
frm.add_start.value = '';
frm.add_finish.value = '';
frm.add_overtime_hours.value = 'N';
frm.add_date.value = '';
}
function removeRow(rnum) {
jQuery('#rownumhours'+rnum).remove();
}
</script>
<tr>
<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="1" size="1" maxlength="1" />
</span></span>
<span class="text"><span class="hours">
<input onclick="addhours(this.form);" type="button" value="Add Labour" />
</span></span>
</p>
<p class="headings"><span class="text"><span class="hours">
<span class="info">(This row will not be saved unless you click on "Add Labour" first) </span></span></span>
</p>
</div>
</td>
<td width="7"></td>
</tr>
<tr>
<td> </td>
</tr>
と呼ばれています。
は、あなたがあなたのコード内のいくつかのエラーを持っているあなたに
こんにちはGaetanoM私のコードを見ていただきありがとうございます。残業時間はまだ伝わっていないようですが、私はメインページでそれを変更しました。また何らかの理由で私が最初の行に入れた日付は23/08/2016であり、新しい行にプロポジットするときは2016-08-23を示します。 –
こんにちはgaetanoM本当にありがとうございました。私は今行くと、最も近いものについて学びます。以前はdivをデータベースに保存して、既存のコードの変更をその変更から変更する必要があります。私はそれがまだデータベースを埋めるために同じ名前を作成していると仮定します。私はまた、データベース値にこのチェックボックスを挿入したいと思いますか?どうもありがとうございます。 –
ありがとうございます。私は、チェックボックスがオンになっているかどうかに応じて、チェックボックスの値を0または1にコピーしようとしています。私は新しいテキストボックスに.valを使用しようとしましたが、私はそれを正しく取得できません。 –