I had only one function to Add another row to the table id="tblOtherParties" and i worked fine, but when I added the second function to do the same with the table id="tblHospitalAction" I get the error of unterminated string constant, but I dont see why as its the same as the first function.
任何帮助都将受到高度赞赏。
我有以下职能:
<script type="text/javascript">
var counter = 1;
function createNewRow (text1,text2){
var first = counter++;
$( #tblOtherParties > tbody ).append( <tr><td>
<input type="text" id="txtName_ +first+ " value=" +text1+ " />
</td><td>
<input type="text" id="txtRole_ +first+ " value=" +text2+ " />
</td><td>
<a class="deleteBtn"/>
</td></tr> );
}
var counterHA = 1;
function createNewRowHA (text1,text2){
var first = counterHA++;
$( #tblHospitalAction > tbody ).append( <tr>
<td>
<input type="text" id="txtH_ +first+ " value=" +text1+ " />
</td>
<td>
<input type="text" id="txtA_ +first+ " value=" +text2+ " />
</td><td><a class="deleteBtn"/></td>
</tr> );
}
$(document).ready(function(){
$(".deleteBtn").live("click", function(){
$(this).closest( tr ).not( :only-child ).remove();
});
$( #btnAddOther ).click(function() {
createNewRow( , );
});
$( #btnAddHA ).click(function() {
createNewRow( , );
});
});
</script>
下表
<div >
<span style="float:left;padding-top:34px;"><b>Other involved parties</b></span>
<table style="float:left;" id="tblOtherParties">
<thead>
<tr>
<td class="title">Name</td>
<td class="title">Role</td>
<td><input type="button" id="btnAddOther" value="Add"/></td>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" id="txtName_0" size="35"/></td>
<td><input type="text" id="txtRole_0" size="35"/></td>
<td><a class="deleteBtn" /></td>
</tr>
</tbody>
</table>
</div>
<div >
<span style="float:left;><b>Other involved parties</b></span>
<table style="float:left;" id="tblHospitalAction">
<thead>
<tr>
<td class="title">Name</td>
<td class="title">Role</td>
<td><input type="button" id="btnAddHA" value="Add"/></td>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" id="txtH_0" size="35"/></td>
<td><input type="text" id="txtA_0" size="35"/></td>
<td><a class="deleteBtn" /></td>
</tr>
</tbody>
</table>
</div>