我在changeStatus.jsp
下面的代码中有一个表格。现在我必须通过一个 jquery 函数清除所有表数据,该函数应该包含在下面的changeStatus.js
代码中。请帮忙解决。
更改状态.jsp:
<table class="data" style="width: 100%" id="${ns}changeStatusTable" style="table-layout:fixed; word-wrap: break-word">
<thead>
<tr>
<th style="width: 10%">Cable</th>
<th style="width: 7%">Pair</th>
<th style="width: 25%">Defective Code</th>
<th style="width: *">Remarks</th>
<logic:equal name="ChangeStatusBean" property="rowError" value="false">
<th style="width: 30%">Error Message</th>
</logic:equal>
</tr>
</thead>
<tbody>
<logic:iterate id="rowData" indexId="idx" name="ChangeStatusBean"
property="rowData">
<tr style="width: 100%">
<td style="width: 10%" id=cable" ><html:text value="" styleId="${ns}cable1" property="cable" maxlength="10" style="width:10em" /></td>
<td style="width: 7%" id="pair"><html:text value="" styleId="${ns}pair1" property="pair" maxlength="4" style="width:7em"/></td>
<td style="width: 25%" id="code"><html:select styleId="${ns}defectiveCode" name="ChangeStatusBean"
property="defectiveCode" style="width:275px" >
<html:option value="">Select</html:option>
<html:optionsCollection property="defectiveCodeList" label="value" value="value" />
</html:select></td>
<td style="width: *" id="remarks"><html:text value="" styleId="${ns}remark" property="remark" style="width:275px" maxlength="14"/></td>
<logic:equal name="ChangeStatusBean" property="rowError" value="false">
<td style="width: 30%" id="errorMessage"><html:text value="" styleId="${ns}errorMsg" property="errorMessage" style="width:275px" /></td>
</logic:equal>
</tr>
</logic:iterate>
</tbody>
</table>
更改状态.js:
ChangeStatusPage.prototype.clearTableData = function(){
var $table = $(this.hashtag + this.ns + "changeStatusTable");
var $rows = $table.find('tr').length;
alert("no of rows: "+$rows/2);
for(var i=1;i<$rows/2;i++){
$(this.hashtag + this.ns + "cable"+i).val("");
}
return false;
};