hi friends need to display the questions and options using radio button such as online quiz ,, i tried but sequentially iam getting a first question with fist options of all questions ,, kindly help me to display first question with its options and second questions with its options
thanks in advance

Edited by vidyya06

4 Years
Discussion Span
Last Post by urtrivedi

let me know how you are retriving the data

what i mean is are you getting data from databse or somewhere else?

can you describe the structure of your data?

so that we will try to give the solution otherwise its hard to suggest any solution

Edited by radhakrishna.p: getting information about the problem


yes iam using sql server 2000,where my table name is qbank(id,question,optionB,optionC,optionD,optionE,Ans) i have to retrive the data using arraylist and hav to display randomly in jsp page same as online test, from the database it has to retrive the data and display with questions and options ,if user clicks next button the next question should come ,if clicks previous button it should go prevoius question. every time a user come for test it should retrive data from db randomly and make them to atten test .after finishing test the clicked answer should be saved in db . its quite urgent .thanks in advance


go through the bellow link which gives an idea to build a solution for your problem


in that question and answers are taken as static data . if you try to get those data dynamically then your problem will be solved i think

first try it yourself

if you have any doubts we are here to help you

Edited by radhakrishna.p: giving clarity on the solution

<%@page import="java.sql.*"%>
<form method="post" action="result.jsp">
<table bordercolor="red" border="1">
Connection con = DriverManager.getConnection("jdbc:odbc:univkey","sa","sql");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from C");

    //String q=rs.getString("question");
    ResultSetMetaData rsmd=rs.getMetaData();
<td><INPUT TYPE=RADIO NAME=\""+n+"\" VALUE=\""+"a\"   checked=\"checked\">&nbsp;(a)&nbsp;<code>"<%=rs.getString("A") %>"</code><br></td>
<td><INPUT TYPE=RADIO NAME=\""+n+"\" VALUE=\""+"a\"   checked=\"checked\">&nbsp;(b)&nbsp;<code>"<%=rs.getString("B") %>"</code><br></td>
<td><INPUT TYPE=RADIO NAME=\""+n+"\" VALUE=\""+"a\"   checked=\"checked\">&nbsp;(c)&nbsp;<code>"<%=rs.getString("C") %>"</code><br></td>
<td><INPUT TYPE=RADIO NAME=\""+n+"\" VALUE=\""+"a\"   checked=\"checked\">&nbsp;(d)&nbsp;<code>"<%=rs.getString("D") %>"</code><br></td>
<td><INPUT TYPE=RADIO NAME=\""+n+"\" VALUE=\""+"a\"   checked=\"checked\">&nbsp;(e)&nbsp;<code>"<%=rs.getString("E") %>"</code><br></tr>
catch(Exception e)
<tr><td ><input type="submit" value="Finished"></td></tr>
<tr><td ><input type="button" value="Prevoius"></td></tr>
<tr><td ><input type="button" value="Next"></td></tr>

hi friend ,, kindly help me on jsp not java script ,,i hav to retrive one by one question using arraylist .


i think we can't acieve this requirement without javascript support.

what i mean is we cant assign the html button events to iterate arraylist which is placed inside jsp scriptlet.

so you have to wait for better idea from anyone of the experts over here

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.