I have this code and I am displaying contents from database in the browser.In database I have questions for survey with options as answers.For each question users have to select any one of the four options.I am using radio buttons for getting user response.I am showing the output that I am getting
tab.JPG
The problem is that I want that users should be able to select only one option out of the 4 options for a question but this code is making me able to select all the four options for a question.Conversely it is allowing me select only one option for a column while it should allow me to select multiple.Like if you look at the first column of the options(3rd column from left) than it allows me select only one option throughout the column.I want to have this on the row and not column.Please can anyone help me with this?
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page import="java.sql.*" %> <%@ page import="java.io.*" %> <html> <head> <title>display</title> </head> <body> <h2>Data</h2> <% try { Connection connection = null; Statement statement = null; ResultSet rs = null; System.out.println("loading class") ; Class.forName("com.ibm.db2.jcc.DB2Driver"); System.out.println("after loading class"); connection = DriverManager.getConnection("jdbc:db2://localhost:50000/Simple","administrator","welcome2sa2"); System.out.println("after conncetion class"); System.out.println(connection.getClass()); statement = connection.createStatement(); String QueryString = "select * from question"; rs = statement.executeQuery(QueryString); %> <TABLE cellpadding="15" border="1" style="background-color: #ffffcc;"> <% while (rs.next()) { %> <TR> <TD><%=rs.getString(1)%></TD> <TD><%=rs.getString(2)%></TD> <TD><input type='radio'name='radio1'><%=rs.getString(3)%></TD> <TD><input type='radio'name='radio2'><%=rs.getString(4)%></TD> <TD><input type='radio'name='radio3'><%=rs.getString(5)%></TD> <TD><input type='radio'name='radio4'><%=rs.getString(6)%></TD> </TR> <% } %> <% rs.close(); statement.close(); connection.close(); } catch (Exception ex) { %> <font size="+3" color="red"></font> <% out.println("Unable to connect to database."); } %> </TABLE> </body> </html>