2017-11-23 10 views
-1

こんにちは私はjspページのデータベースから本の名前を取得したいです。私はすべての本の名前を取得していますが、私のrequirmentは選択した本をチェックボックスで更新したいのですが、 ...jspでチェックボックスの値を取得する方法

ここは私のjspコードです...事前に感謝します。

<form action="book1.jsp" name="f1"> 
    <table border="1" align="center"> 
     <caption>Select Book for Update</caption> 
     <% 
      while(rs.next()) 
      { 
     %> 
     <tr> 
      <th colspan="2">Book name</th>   
      <td><%= rs.getString("bookname") %></td> 
      <td> <input type="checkbox" value="${row.id}" name="b1"/> </td> 
     <% } %> 
     </tr>  
     <tr> 
      <td colspan="3"><input type="submit" value="Update" ></td> 
     </tr> 
    </table>   

+1

[JSPのチェックボックスをチェックします方法]の可能な重複(https://stackoverflow.com/questions/12396828/how-to-get-checked-checkboxes-in- jsp) – Yash

答えて

0
<%! String[] books; 
books = request.getParameterValues("b1"); 
if (books != null) 
{ 
    for (int i = 0; i < books.length; i++) 
    { 
    out.println ("<b>"+books[i]+"<b>"); 
    } 
} 
else out.println ("<b>none<b>"); 
%>