dnvsp
dnvsp

Reputation: 201

Radio button holds only one value in table?

I have a table in html form with dynamically generated from database.So,here I used for loop.Now what's the my problem is in entire table radio button holds only one value.But I want to hold one value in each row and unable to find the solution.For any Help thanks in advance.

    <table class="table" id="attendanceTableId" style="width: 500px;">
    <%
    for(int i=0;i<=se.size()-1;i++) {
    %>
      <tr>
         <td><input type="textbox" name="studentName" value="<%=se.get(i)%>" style="background-color: #A7C5C2" readonly></td>

         <td><input type="radio"  name="status" value="Present" style="width: 15px; height: 15px;" />Present

         <input type="radio" name="status" value="Absent" style="width: 15px; height: 15px;">Absent</td>
      </tr>

    <%
    }
    %>
    </table>                           

Upvotes: 0

Views: 101

Answers (1)

jervi
jervi

Reputation: 160

Use name="status_<%= i %>" or something similar for the name parameter of the radio input tags. Currently, they all share the same name, and are therefore grouped together. Each radio button group can only have one selected value. If you include the row index in the name parameter, you will get one radio button group per row.

Upvotes: 1

Related Questions