creation of a form

Ads
 

creation of a form

View Answers

October 29, 2009 at 3:22 PM

Hi Friend,

We have taken radiobuttons in our application, you can take textarea, textfield etc.

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);
%>

For more information,please visit the following link:

http://www.roseindia.net/jsp/online-quiz-application-jsp.shtml

Thanks


Ads









Related Tutorials/Questions & Answers:
Creation of xml
Creation of xml  Hi, I need to fetch details from my database and to create a xml file containing all those datas...My database datas are in key value pair... AppID Label Value 12345 Applicant name XXXX 12345 Masterno
Creation of methods
Creation of methods  I have a only single class and its having only one method ie., main method only.... i need to develop another method that is to reduce my switching code package org.bankPackage.one; import java.util.Scanner
Advertisements
Random Creation of password
Random Creation of password  Dear Sir I have created a form with some details in it.When clicking on the submit button it gives me a password .....Details and the password is saved in the database....The password has
How to: generic array creation
How to: generic array creation  How to: generic array creation
object creation - Subversion
object creation in Java  In how many ways we can create objects in Java
xml file creation in java
xml file creation in java  how to create xml file in java so that input should not be given from keyboard. and that file should be stored.   Please visit the following links: http://www.roseindia.net/tutorial/java/xml
Session creation and tracking
Session creation and tracking  1.Implement the information persistence across servlet destroy or servlet container start/stop. Write a servlet such that when it is stopped (either by container shutdown or servlet stop
bean creation exception
bean creation exception  hi i am getting exception while running simple spring ioc program Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class
Chatbox creation problem
Chatbox creation problem  i have one chat box in my web site and i assigned fixed position to that div.that is workin in mozill but it is not working in ie . thank you`print ("<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
forums creation using spring with hibernate?
forums creation using spring with hibernate?  how to write mandatory fields with validations in forms using spring with hibernate? give me detailed example
ModuleNotFoundError: No module named 'music-album-creation'
ModuleNotFoundError: No module named 'music-album-creation'  Hi...: No module named 'music-album-creation' How to remove the ModuleNotFoundError: No module named 'music-album-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'music-album-creation'
ModuleNotFoundError: No module named 'music-album-creation'  Hi...: No module named 'music-album-creation' How to remove the ModuleNotFoundError: No module named 'music-album-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'music-album-creation'
ModuleNotFoundError: No module named 'music-album-creation'  Hi...: No module named 'music-album-creation' How to remove the ModuleNotFoundError: No module named 'music-album-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'music-album-creation'
ModuleNotFoundError: No module named 'music-album-creation'  Hi...: No module named 'music-album-creation' How to remove the ModuleNotFoundError: No module named 'music-album-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'xseed-max-box-creation'
ModuleNotFoundError: No module named 'xseed-max-box-creation'  Hi...: No module named 'xseed-max-box-creation' How to remove the ModuleNotFoundError: No module named 'xseed-max-box-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'xseed-minicampus-creation'
ModuleNotFoundError: No module named 'xseed-minicampus-creation'  Hi...: No module named 'xseed-minicampus-creation' How to remove the ModuleNotFoundError: No module named 'xseed-minicampus-creation' error? Thanks  
dynamic creation of multiple drop-down menus
dynamic creation of multiple drop-down menus  can anybody plz help me in coding for dynamic creation of multiple drop-down menus in a webpage using ajax/js/html/css
form validation
form validation  how the form validation is done in jsf form using javaScript
Creation of MultiThreads
Creation of Multiple Threads       Like creation of a single thread, You can also create more than one thread (multithreads) in a program using class Thread
Intranet Website creation - plz help me
Intranet Website creation - plz help me   hi.. I have assign with the intranet website creation work..right from scratch to end..And honestly I know nothing about it.My domain is totally different .. can anybody pls help me
Core java interview question, object creation.
Core java interview question, object creation.  How can we restrict to create objects for more than five? That means i want only 5 objects, how to restrict to create 6th objects
print a form of *
print a form of *   * *** ***** ******* ********* ******* ***** *** *   Post the format properly
Multipage form
Multipage form  I have a multipage form in php with 2 pages wnhen i submit the form data from both the pages should go in database how should i pass teh data from 1st page to 2nd page and then put the entire form data in mysql
jsp form
jsp form  hi sir, one got one got in jsp form after entering the data into the form the data is not saving in the database i will send you code of two forms if dnt understand my problem
submit a form
submit a form  How can we submit a form without a submit button
Limit the Class Object Creation
Limit the Class Object Creation In this section you will learn about how a class object creation can be a restricted to a fix number of times... to restrict the object creation of a class. This is a simple code in Java where I have
Table Creation
object creation
Image_creation
reports creation
Table Creation

Ads