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

Recommended Answers

All 11 Replies

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

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

We need to look at your code to find the problem. Only statement can not help.

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

http://www.javascriptkit.com/script/cut142.shtml

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

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

while(rs.next())
{
    //String q=rs.getString("question");
    ResultSetMetaData rsmd=rs.getMetaData();
    //out.println(colcount);
    %>
    <tr><td><%=rs.getInt("Id")%></td><td><%=rs.getString("question")%></td>
<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)
{
out.println("err");
}
%>
<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>
</table>
</form>
</html>

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

kindly help me using arraylist

is there anyone expert ? to solve this

right now what problem you face?
Post your table struture and sample data here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.