Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi to all, I am developing an online examination system using JSP,javascript. This is my paper203.jsp page. This project is for online test 1 Question and 4 ans. There are next,previous buttons to choose questions and mark button to mark the question so that the person can easily identify the question they wish to try again. The problem is that the mark button is not working. Please suggest me what to do?


The code is as follows:

HTML
function mark()
{
    <%
        int p=0;
        if(request.getParameter("hidden5")!=null)
        {
            p=Integer.parseInt(request.getParameter("hidden3"));

        }
        f[p]=true;


    %>
}
function cls_wndw(){
    window.close();
}
This is the view:





<%
            Connection conn=null;
            Statement st = null;
            ResultSet rs=null;

            try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydatabase","root","stardust");
                st= conn.createStatement();
                rs = st.executeQuery("select * from quesbanklog1");
                int i=0;
                while(rs.next()&&current==0&&flag!=1&&i<totlques) {
                    order[i]=rs.getString(1);
                    ques[i][0]=rs.getString(1);
                    ques[i][1]=rs.getString(2);
                    ques[i][2]=rs.getString(3);
                    ques[i][3]=rs.getString(4);
                    ques[i][4]=rs.getString(5);
                    ques[i][5]=rs.getString(6);
                    ques[i][6]=rs.getString(7);
                    i++;
                }

                if(current==0&&flag!=1){
                    Collections.shuffle(Arrays.asList(order));
                    session.setAttribute("ordr",order);
                    session.setAttribute("quest",ques);
                    session.setAttribute("flag",String.valueOf(1));
                }

                if (current>(nq-1)) {%>
                    <table border="1">
                        <%
                    for(int k=1;k<=current;k++){
                        %><tr><td><input type="radio" name="radio1" value="<%=(k-1)%>"/></td><%
                        out.print("<td>Q"+k+"</td>");
                        if(stats[k][1]=="r"){
                            out.print("<td>Review</td>");
                        }
                        else{
                            out.print("<td>Unattempted</td>");
                        }
                        if(f[k]==true){
                            out.print("<td>Flagged</td>");
                        }
                        else{
                            out.print("<td>-----</td>");
                        }

                        out.print("</tr>");

                    }
                    %>

                    </table>
                    <br />
                   value="Mark"  onclick="mark()"/>


<%       }
       }
    }
}
catch (Exception ex) {
                out.println(ex.getMessage());
            } finally {
                //close all the connections.
                //rs.close();
                st.close();
                conn.close();
            }
    %>


</form>

</body>

</html>
Posted
Updated 26-Apr-15 19:22pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900