【问题标题】:Cannot retrieve values from added rows (jquery) in JSP using servlet无法使用 servlet 从 JSP 中添加的行 (jquery) 中检索值
【发布时间】:2016-09-24 17:00:30
【问题描述】:

我有一个表格,您可以在其中单击 addRowButton 时添加一行。这是它的代码:

$('#addRowButton').click(function () {
                        $('#data').append(
                                '<tr>' +
                                '<td>IGA01</td>' +
                                '<td>' +
                                '<div class="col-sm-10">' +
                                '<input type="text" name="description" class="form-control no-border" id="description" placeholder="Enter Institutional Graduate Attribute">' +
                                '</div>' +
                                '</td>' +
                                '<td>' +
                                '<div class="col-sm-10">' +
                                '<input type="text" name="remarks" class="form-control no-border" id="remarks">' +
                                '</div>' +
                                '</td>' +
                                '<td>' +
                                '<button type="button" class="btn btn-success btn-xs"><i class="fa fa-edit"> </i></button>' +
                                '<button type="button" id="deleteRow" class="btn btn-danger btn-xs"><i class="fa fa-trash"></i></button>' +
                                '</td>' +
                                '</tr>'
                                );

我的问题是当我尝试检索添加的行的值时,我无法获取它们。我只能检索未动态添加的行的值。 .这是 servlet 的代码(for 循环是让我查看 servlet 是否能够检索输入):

    String[] codeIGA = request.getParameterValues("codeIGA");
    String[] description = request.getParameterValues("description");
    String[] remarks = request.getParameterValues("remarks");

    for (int y = 0; y < codeIGA.length; y++) {
        System.out.println("codeIGA: " + codeIGA[y]);
        System.out.println("description: " + description[y]);
        System.out.println("remarks: " + remarks[y]);
    }

【问题讨论】:

标签: jquery jsp servlets dynamic html-table


【解决方案1】:

我无法检索已添加行中的值的原因是,当我在添加行函数中看到我忘记添加 &lt;input type="hidden" name="codeIGA" class="readonlyWhite" id="codeIGA" value="" /&gt; 时,我的 for 循环得到了 codeIGA.length

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 1970-01-01
    • 2015-01-31
    • 1970-01-01
    • 2018-10-26
    • 2014-06-27
    • 1970-01-01
    相关资源
    最近更新 更多