Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts to retrieve from radiobox and comparing with a string
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


manoj
to retrieve from radiobox and comparing with a string
1 Answer(s)      5 years and 3 months ago
Posted in : Struts



Advertisement
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
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
Advertisements
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 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
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
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
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
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 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 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
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 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
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 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>
Comparing tables
Comparing tables  How to compare two or more tables in the Mysql database using jdbc
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
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 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
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 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 is a common task. MYSQL provides different ways of inserting and fetching dates from
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
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 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 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
Advertisements
 

 

 

DMCA.com