下面是我在应用程序中显示的表格示例:
Marks Per Answer Total Marks Marks Remaining
(blank text input)
(blank text input) 6 6
(blank readonly text input) 4 0
我遇到的问题是,应该发生的是表中的任何只读文本输入应显示与“总分”列下的数字相同的值。所以表格应该如下所示:
Marks Per Answer Total Marks Marks Remaining
(blank text input)
(blank text input) 6 6
(readonly text input value='4') 4 0
我的问题是,为了在只读文本输入中显示正确的值,我需要在下面的代码中进行哪些更改?
if ($("[class*=q" + i + "_mark]").length == 1) {
//alert(t_marks);
var t_marks = $("[class*=q" + i + "_ans]");
var t_marksHtml = t_marks.html();
t_marks.html("0");
$("[class*=q" + i + "_mark]").val(t_marksHtml).attr('readonly', true);
//$("[class*=q"+i+"_mark]").attr('readonly',true);
}
下面是 HTML:
<table border='1' id='markstbl'>
<thead>
<tr>
<th class='answermarksth'>Marks per Answer</th>
<th class='totalmarksth'>Total Marks</th>
<th class='noofmarksth'>Marks Remaining</th>
</tr>
</thead>
<tbody>
<tr class="questiontd">
<td class="answermarkstd">
<input class="individualMarks q1_mark_0" q_group="1" name="answerMarks[]" id="individualtext" type="text" />
</td>
<td class="totalmarkstd" rowspan="2">6</td>
<td class="noofmarkstd q1_ans_text" q_group="1" rowspan="2"><strong>5</strong></td>
</tr>
<tr class="questiontd">
<td class="answertd" name="answers[]">D</td>
<td class="answermarkstd">
<input class="individualMarks q1_mark_0" q_group="1" name="answerMarks[]" id="individualtext" type="text" />
</td>
</tr>
<tr class="questiontd">
<td class="answermarkstd">
<input class="individualMarks q2_mark_0" q_group="1" name="answerMarks[]" id="individualtext" type="text" />
</td>
<td class="totalmarkstd" rowspan="1">6</td>
<td class="noofmarkstd q2_ans_text" q_group="1" rowspan="1"><strong>5</strong></td>
</tr>
</tbody>
</table>