【问题标题】:how to retrieve values of various checkbox groups from one jsp page to another如何从一个jsp页面检索各种复选框组的值到另一个
【发布时间】:2011-04-27 03:17:22
【问题描述】:

这是示例代码

<input type="radio" name="r1" value="A">
<input type="radio" name="r1" value="B">


<input type="radio" name="r2" value="X">
<input type="radio" name="r2" value="Y">

等等

<input type="radio" name="r_" value="P">
<input type="radio" name="r_" value="Q">

在这里,我从数据库中检索了这个单选按钮框,并通过 while 循环显示在 jsp 页面上

While(resultSet.next()){

}

现在我要检查用户在另一个 jsp 页面上选择的值。 那么,我怎样才能检索检查的值? 主要问题是,在数据库中,管理员可能会增加或减少行数。所以我不需要每次都更改代码。

【问题讨论】:

    标签: jsp


    【解决方案1】:

    r_的总量添加到隐藏字段中:

    <input type="hidden" name="count" value="${count}" />
    

    如下获取:

    int count = Integer.valueOf(request.getParameter("count"));
    

    并获取所有复选框值如下:

    for (int i = 1; i <= count; i++) {
        String[] checked = request.getParameterValues("r" + i);
        // ...
    }
    

    【讨论】:

      猜你喜欢
      • 2013-08-31
      • 2019-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多