to retrieve from radiobox and comparing with a string

to retrieve from radiobox and comparing with a string

View Answers

August 19, 2009 at 4:40 PM

Hi Friend,

Create a table ans(ques,op1,op2,op3,op4,op5,ans) in the mysql database and try the following code:

1)radio.jsp:

<%@page import="java.sql.*"%>
<form name="form" method="post" action="result.jsp">
<table>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn =DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from answers");
int i=0;
while(rs.next()){
%>
<tr>
<td><%=rs.getString(1)%></td>
<td><input type="radio" name="radio<%=i%>" value="<%= rs.getString(2) %>"></td><td><%=rs.getString(2)%></td>
<td><input type="radio" name="radio<%=i%>" value="<%= rs.getString(3) %>"></td><td><%=rs.getString(3)%></td>
<td><input type="radio" name="radio<%=i%>" value="<%= rs.getString(4) %>"></td><td><%=rs.getString(4)%></td>
<td><input type="radio" name="radio<%=i%>" value="<%= rs.getString(5) %>"></td><td><%=rs.getString(5)%></td>
<td><input type="radio" name="radio<%=i%>" value="<%= rs.getString(6) %>"></td><td><%=rs.getString(6)%></td>
<td><input type="hidden" name="ans<%=i%>" value="<%= rs.getString(7) %>"></td>

</tr><%
i++;
}
%>
<tr><td><INPUT type="submit" name="submit" value="Submit"></td></tr>
</table>
</form>

2) result.jsp:

<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%
String id[]= new String[10];
for(int i=0;i<10;i++){
id[i]=request.getParameter("radio"+i);
}
String str[]= new String[10];
for(int j=0;j<10;j++){
str[j]=request.getParameter("ans"+j);
}
boolean isCorrect = Arrays.equals(id,str);
out.println("Your Answers are : " + isCorrect);
%>

Thanks









Related Tutorials/Questions & Answers:
to retrieve from radiobox and comparing with a string - Struts
to retrieve from radiobox and comparing with a string  im creating a exam application in jsp which makes students to attend java questions.. created an array of radio buttons below is the code
Get Character from String
toCharArray() to convert string to character array. 3. Retrieve character from... Get Character from String     ... of character and retrieve elements from that character array one by one
Advertisements
retrieve record from table
retrieve record from table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field table. Actually
How to retrieve image from database
How to retrieve image from database  hi........ How to retrieve image from database when it is stored. I have stored image in postgresql and want to retrieve in java form. Can u tel me hw to do? I am trying n able to do also
retrieve from database........
retrieve from database........  <p>hi i am not able to retrieve string from database to a text box in web page my code is as follows:-</p>...,password); String query = "select * from employee"; st = con.createStatement
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database
how to retrieve data from database  unable to retrieve data from database using mySQL by using jsp sessions and beans for editing
Retrieve The Data From MySql Datbase
Retrieve The Data From MySql Datbase   How to Retrieve The Data From MYSQL database TO Use Select the Emp_id Option.And Also Search Option
how to retrieve a checkbox value(retrieve from DB)
how to retrieve a checkbox value(retrieve from DB)   I facing a problem with checkbox value that already exists inside the database. so how can I retrieve those value from another database table? the table subject and service
retrieve data from database with hyperlink
retrieve data from database with hyperlink  sir....i have one table called 'name' having two values i have to retrieve those data with a hyperlink... have values C C++ i have to retrieve and if i click C its sub categories should
How to retrieve record from table
How to retrieve record from table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field table
Retrieve Value from Table - Hibernate
Retrieve Value from Table   Hai friend, I need help, How can i retrieve values From database using hibernate in web Application. As I new to hibernate I couldn't find solution for this problem.. Can anyone help please.. 
retrieve record from the field table
retrieve record from the field table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field table
Data retrieve from mysql database
Data retrieve from mysql database  Hi sir, please give some example... = DriverManager.getConnection(url+dbName,userName,password); String query = "select * from... from the dropdown, related data will get displayed on the textboxes. Here we have
Retrieve the String using expression
Retrieve the String using expression       This Example describes the way to retrieve the String... The steps involved in program NotLookahead.java are described below:- String
How to retrieve a field from SQLite to Edittext in android
How to retrieve a field from SQLite to Edittext in android  Hi... Im new to android.. i do no how to retrieve a field from database(SQLite). I'd like to retrieve password field to my edittext in my app.. This is my code
How to retrieve a field from SQLite to Edittext in android
How to retrieve a field from SQLite to Edittext in android  Hi... Im new to android.. i do no how to retrieve a field from database(SQLite). I'd like to retrieve password field to my edittext in my app.. This is my code
retrieve data from mysql database
retrieve data from mysql database  hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant data from mysql... * from testtable where Fname like '%$term%'"); while ($row = mysql<em>
Extarct string from PDF
Extarct string from PDF  how can i search a particular character from pdf? also extarct string from a pdf document
Removing characters from a string
Removing characters from a string  Removing characters from a string...(String []args){ String str="Hello 123.you are At 3456"; String...() method removes all blank spaces in the string
how to use bean to retrieve data from database
how to use bean to retrieve data from database  how to use bean to retrieve data from database   poda sendru
How to retrieve image from database in Servlet?
How to retrieve image from database in Servlet?  Hi, How to retrieve image from database in Servlet? Thanks   Hi, Please check the tutorial Retrieve image from database using Servlet. Thanks
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
jsonelement from string
jsonelement from string  Hi, I have to create jsonelement from string in Java. How to do this? Thanks   Hi, You can use following code: Gson gson = new Gson(); String data ="Hello"; JsonElement ele
Java dom from string
Java dom from string  Hi, How to create dom tree from string data? I am trying to search the example for java dom from string. Thanks... static void main(String[] args) { String url="http://www.roseindia.net
Retrieve multiple data from database into Table.....
Retrieve multiple data from database into Table.....   hi........... I want to Retrieve multiple data from database into Table but i am not able to.... i am only able to retrieve one value not more than that. means in my
Retrieve data from databse using where in JSP
Retrieve data from databse using where in JSP  Hi, can somebody help me? I have a jsp page. in that i want to get data from the database where...=request.getParameter("username"); String sql; sql="SELECT * FROM register WHERE
retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir... that retrieve the integer values from the database and stored in the integer variables. In addition to it, we have added numbers that are retrieved from
Retrieve date from MYSQL database
Retrieve date from MYSQL database In this tutorial, you will learn how to retrieve date from database. Storing and Retrieving dates from the database... to retrieve the date of birth of persons from the database table. For this, we have
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used... the blog image from database. How to retrieve blob image from database in JSP?   Hi, Please check the tutorial Retrieve image from database using
How to retrieve and display image from database in Java?
How to retrieve and display image from database in Java?  Hi, I am writing a web application for reading the data from database and displaying.... Please check the it at How to store and retrieve image from database in JSP
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one... and retrieve image from database in JSP? Thanks   HI, You can use... the image. Check this example: Retrieve image from database using Servlet. Thanks
retrieve data from database using jsf
retrieve data from database using jsf  Hello I want an example of source code to retrieve data from database i have a database (oracle) name as db1...),, name ,and city I want after enter value in textbox according idauthor i retrieve
how to retrieve images from database to jsp?
how to retrieve images from database to jsp?  Hi sir,i want to stores...=con.createStatement(); String strQuery = "select * from data"; ResultSet rs...(); String strQuery = "select image from data where id="+id; ResultSet rs
How to retrieve image from mysql database in JSP?
How to retrieve image from mysql database in JSP?  Hi, I need JSP... to retrieve image from mysql database in JSP? Thanks   Hi, You can write SQL query to find the data from database and get the image from resultset using
Retrieve values from database using views
Retrieve values from database using views  hi......... I have a huge... the columns which are required. As my front end is java swings i want to retrieve data from that created views and display on form . I am trying to do so but its
Retrieve value of radio button from database to form
Retrieve value of radio button from database to form  var gn=document.getElementsByName("empg"); //empg is name of radio input type. for(var i=0;i
remove a substring from a string
remove a substring from a string  Please I jave an arraylist composed as follwoing [w1, w2, w3, w4, w1.w2.w3, w2.w3.w4, w3.w4, w2.w4, w1.w3, w1.w2] w2.w4 is a subset of w2.w3.w4 ?how I recognize it also ADS_TO_REPLACE_1 w1.w3
I have to retrieve these data from the field table
I have to retrieve these data from the field table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
HTML & MYSQL - retrieve record from table
HTML & MYSQL - retrieve record from table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field
MYSQL retrieve record from Data table
MYSQL retrieve record from Data table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field
retrieve record from table and show it in HTML
retrieve record from table and show it in HTML  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
Retrieve data from database in swing application
Retrieve data from database in swing application  I want to retrive data(doctor name,specilization,date) from my sql database... { public static void main(String[]args){ JFrame f=new JFrame(); JPanel
Dropdown code to retrieve result from oracle database
Dropdown code to retrieve result from oracle database  Hi Friends, I... retrieve the result from Oracle database.We have procedures created already.Just... that will retrieve values from the database into dropdown. As the user choose any option
Retrieve database from the table dynamically in jsp from oracle using servlet
Retrieve database from the table dynamically in jsp from oracle using... columns dynamically. I want to retrieve the table with all columns dynamically using java servlet from the database in the jsp page
how to store and retrieve image from database
how to store and retrieve image from database  how to store and retrieve images into database(oracle) and how to retrive images from database using jsp   Here is a jsp code that insert and retrieve image from mysql

Ads