User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 425,827 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,994 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 343 | Replies: 0
Reply
Join Date: Jun 2008
Posts: 37
Reputation: guravharsha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
guravharsha guravharsha is offline Offline
Light Poster

How to store Answer avilable in option format in table

  #1  
Jul 22nd, 2008
Hi,
I have one jsp page containing 2o questions retrieved from table along with its possible four-option answer in this manner:
Question1:
Option-a
Option-b
Option-c
Optio-d
All the options are in radio button form. I am trying to store the result of these question test in my final output table:
Structure of this table is:
Eventide -> int(2)->data from another event table
Question id ->int(2) ->data from questionbank table
Serialno ->int(3) ->data from questionbank table
Answer -> varchar(2) -> value of the option selected from above question page>
So, How it is possible to store the result of all question with answer equals to one of the four options in the same row of questioned.
Here questioned is same for all questions:
Here is fillquestion.jsp page:

<%-- 
    Document   : fillquestion
    Created on : Jul 18, 2008, 10:07:43 AM
    Author     : user1
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language ="java" %>
<%@ page import="java.sql.*, javax.sql.*, javax.naming.*,java.io.*,java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Fill-up-Question</title>
    </head>
    <body>
    <form name="fill-ok" action="fill-question-ok.jsp" method="POST">
        
        <table width="50%" border="1" borderColor="#000066" cellspacing="0" cellpadding="5" align="center">
              <TBODY>
	<tr>
		<td colspan="8" align="middle" class="StripColor">
			<font class="FontGeneralBoldWhite">Fill Up the Question</font>
                        
		</td>
	</tr> 
        
        <%
        String ID=request.getParameter("id"); 
        String EVENTID=request.getParameter("EventID");
        Connection connection = null;
        Statement st = null;
        ResultSet rs = null;
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mynewdatabase","root", "root123");
         st=con.createStatement();
           try {
            rs = st.executeQuery("SELECT * FROM questionbank where questionid='"+ID+"'");
        
         while ( rs.next() )
	   {
           %>
	   <tr>
            <input type="hidden" name="eventid" value="EVENTID" />
		
               <td><%=rs.getString("qserialno")%>:&nbsp;&nbsp;<b>Question:</b>
              <%=rs.getString("questionname")%>
		</td>
                </tr>
                <tr>
                    <td><input type="hidden" name="QserialNO" value="<%=request.getParameter("Qserialno")%>"></td>
                <td><b>A:</b><input type="radio" name="opa" value="A" /><%=rs.getString("OptionA")%></td>           
                <td><B>B:</B><input type="radio" name="opb" value="B" /><%=rs.getString("OptionB")%></td>
                <td><B>C:</B><input type="radio" name="opc" value="C" /><%=rs.getString("OptionC")%></td> 
                <td><B>D:</B><input type="radio" name="opd" value="D" /><%=rs.getString("OptionD")%></td>                 	
                </tr>             
		        <%
                           }

                       }   finally
                       {
                           if (rs != null)
                           {
                               rs.close();
                               rs = null;
                           }
                           if (st != null)
                           {
                               st.close();
                               st = null;
                           }

                       }
                      
                   %>
    </table>
    <tr>
                <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="SUBMIT" name="submit" /></TD>
                <td><input type="reset" value="RESET" name="reset" /></td>
                    
	       </tr>
   </form>
   </body>
   </html>


Thanks and Regards
Haresh
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JSP Forum

All times are GMT -4. The time now is 4:26 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC