问题描述:

I want to bind a list object to a dynamic row table jstl form for creation of the object in spring MVC. The table has three buttons:1_submit 2_add row 3_delete row

By clicking on the (add row) or (delete row) buttons the user would be able to add or delete elements from the list.Could any one tell me how should it be done by giving an example? Thanks.

网友答案:

http://bootsnipp.com/snippets/featured/dynamic-table-row-creation-and-deletion

like this.

<div id="add_input_list">
        <div class="inputs">
            <!-- put your item -->

        </div>
    </div>

script

add function.

var html = '<div>' + '<div class="inputs">'+ '<div>your item</div>'+ '</div>' </div>'

$("#add_input_list").append(html);

remove function

var index = $("#add_input_list").children()
                .children().size();

if ($("#add_input_list").children().children().size() > index) {
    $("#add_input_list").children().last().remove();
} else {
    alert('Do not exist to add row.');
}
相关阅读:
Top