Click Add to add the table to increase a

Change the code from Guangxi platform uums project jsp / addOrUpdate.jsp interface (not end before and after use easyui separation) 

// In the table, when the click Add automatically increase his
<table style = "width: 98 % "ID =" Tab "class =" Table Table-bordered Table-Condensed Table-Striped Table-hover Table-responsive ">
<tbody>
<TR>
<TH> property </ TH>
<TH> room </ TH>
< th> Bed Unit </ th>
<th> the number of beds </ th>
<th> the number of operations </ th>
</ TR>
// interface when added during (as when adding a new interface, there is need for the default a blank line, because if there is no blank lines, there is no way to click the Add button, there is no way to automatically add a line)
// was thinking: when data click Add, add a non-empty judge's conduct, if null is not added, or to add, to avoid extra dummy data
<C: = IF Test "$ {applyClasses.cid applyClasses.cid == == null || ''}">
<TR>
<td ><input type='text' name='applyHotelList[0].hotelname' value='' class='inputText'/></td>
<td ><input type='text' name='applyHotelList[0].type' value='' class='inputText'/></td>
<td ><input type='text' name='applyHotelList[0].price' value='' class='inputText'/></td>
<td ><input type='text' name='applyHotelList[0].numberofdeds' value='' class='inputText'/></td>
<td >
<a href='#' class="delRow">删除</a>
<a href="#" onclick=" addRow();" >添加</a>
</td>
</tr>
</c:if>
//在进行修改操作的时候,利用varStatus="status"The status.index (on behalf of subscript), to modify the operation time thinking //: Click modifications when all the hotels previously bound deleted during the Add (but in reality did not use the update statement)
// NOTE: If you do not use index values, when click submit all information will be summarized as a front and add

<c:forEach items="${applyHotels}" var="hotel" varStatus="status">
<tr>
<td><input type='text' name='applyHotelList[${status.index}].hotelname' value='${hotel.hotelname}' class='inputText'/></td>
<td><input type='text' name='applyHotelList[${status.index}].type' value='${hotel.type}' class='inputText'/></td>
<td><input type='text' name='applyHotelList[${status.index}].price' value='${hotel.price}' class='inputText'/></td>
<td><input type='text' name='applyHotelList[${status.index}].numberofdeds' value='${hotel.numberofdeds}' class='inputText'/></td>
<td >
<a href='#' class="delRow">删除</a>
<a href="#" onclick=" addRow();" >添加</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>

//js代码
// delete the code when 
$ (function () {
$ (Document) .on ( 'the Click', 'a.delRow', function () {
var _len = $ ( "# Tab TR") length;.
IF (_len 2 ==) {
Alert ( 'retains at least one row!')
} the else {
$ (the this) .parent () parent () Remove ();..
}
});
});


var nums=${fn:length(giftList)};
nums=nums+1;

//添加一行
function addRow(index){
var _len = $("#tab tr").length;
$("#tab").append("<tr id="+(Number(nums)+Number(1))+" align='center' >"
+"<td ><input type='text' id='spDepartment"+(Number(nums)+Number(1))+"name' name='applyHotelList["+(Number(nums)+Number(1))+"].hotelname' value='' class='inputText'/></td>"
+"<td ><input type='text' id='spDepartment"+(Number(nums)+Number(1))+"name' name='applyHotelList["+(Number(nums)+Number(1))+"].type' value='' class='inputText'/></td>"
+"<td ><input type='text' id='spDepartment"+(Number(nums)+Number(1))+"name' name='applyHotelList["+(Number(nums)+Number(1))+"].price' value='' class='inputText'/></td>"
+"<td ><input type='text' id='spDepartment"+(Number(nums)+Number(1))+"name' name='applyHotelList["+(Number(nums)+Number(1))+"].numberofdeds' value='' class='inputText'/></td>"
+"<td ><a href='#' class='delRow'>删除</a><a href='#'onclick='addRow();' >添加</a></td>"
+"</tr>");
nums=nums+1;
}

Guess you like

Origin www.cnblogs.com/luYing666/p/11590270.html