Results 1 to 6 of 6
  1. #1
    happy is offline Member
    Join Date
    Jun 2011
    Posts
    9
    Rep Power
    0

    Post event handling using servlets

    i hav just started with an "online examination" project . i need some help regarding the event handling done in jsp pages. i have tried using javascript bt on pressing submit button no action is being done..

    this is the jsp page.

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>


    <a href="stud.jsp">
    <input type="button" value="HOME">
    </a>


    <%@page import="java.sql.*"%>
    <%

    HttpSession s= request.getSession();
    Object o=s.getAttribute("Username");
    out.print("<center>");
    //out.println("<br>" +"<br>" +"</center>");
    out.println("welcome- "+o);
    out.println("<br>" +"<br>" +"</center>");

    %>



    <script language="javascript">




    function f11()
    {

    var result=0;

    if(f1.r1[0].checked || f1.r1[1].checked || f1.r1[2].checked || f1.r1[3].checked)
    {
    if(f1.r1[0].checked)
    {
    alert("monkey");
    result=result+1;


    }

    if(f1.r1[1].checked)
    {
    alert(" dog ");

    }

    if(f1.r1[2].checked)
    {}
    msgbox("hello");
    System.out.println("chekd here");
    alert("ASS ");
    }
    if(f1.r1[3].checked)
    alert("cat ");


    }

    if(f1.r2[0].checked || f1.r2[2].checked || f1.r2[3].checked || f1.r2[1].checked)
    {

    if(f1.r2[0].checked)
    {
    alert("crab");
    result=result+1;
    }

    if(f1.r2[1].checked)
    alert("snake");

    if(f1.r2[2].checked)
    alert("dog");

    if(f1.r2[3].checked)
    alert("cockroach");


    }

    alert(result);


    </script>
    </head>

    <BODY bgcolor="red">


    <H1> <center>ONLINE MCQ EXAM</center></H1>




    <H2> QUESTION1: </H2>

    <b>NATIONAL ANIMAL:</b>



    <form name="f1">
    monkey:<input type="radio" name="r1" ><br>
    DOG:<input type="radio" name="r1" ><br>
    ass:<input type="radio" name="r1"><br>
    cat: <input type="radio" name="r1"><br><br>


    <h2>Question2:</h2>
    <h3> which of the following seems delicious to u:</h3>
    crab:<input type="radio" name="r2" ><br>
    snake:<input type="radio" name="r2" ><br>
    dog:<input type="radio" name="r2"><br>
    cockroach: <input type="radio" name="r2">


    <br><br><br><br>
    <center>
    <input type="button" value="submit" name="b1" onclick="f11();">

    </center>
    </form>
    </BODY>
    </HTML>

  2. #2
    happy is offline Member
    Join Date
    Jun 2011
    Posts
    9
    Rep Power
    0

    Default

    nw javascript is running . there was some prblm wid d brackets..

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,123
    Rep Power
    20

    Default

    So.
    Is this closed then?

  4. #4
    happy is offline Member
    Join Date
    Jun 2011
    Posts
    9
    Rep Power
    0

    Default

    thnks for ur reply.

    no actually im getting some prblm with submitting the values of the textfields to the database.
    i have handled the values of the radiobuttons thru javascript, by don't know how to place these values to database. i m using sql as bckend..

  5. #5
    happy is offline Member
    Join Date
    Jun 2011
    Posts
    9
    Rep Power
    0

    Default

    to be more specific wid my problem......


    <form name="f1">
    netscape:<input type="radio" name="r1" ><br>
    mozilla:<input type="radio" name="r1" ><br>
    facebook:<input type="radio" name="r1"><br>
    safari: <input type="radio" name="r1"><br><br>
    </form>


    javascript:

    function f11()
    {
    alert("entererddd");
    var result=0;
    x= document.f1;
    if(x.r1[0].checked || x.r1[1].checked || x.r1[2].checked || x.r1[3].checked)
    {
    if(x.r1[0].checked)
    {

    result=result+1;


    }

    i have to update the value of dis "result " to my database...

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,123
    Rep Power
    20

    Default

    I have an aversion to txt spk.
    Please type properly if you want people to actually understand your requirements, especially if English isn't your first language.

    As for your problem, where's the Java?

Similar Threads

  1. Event handling
    By smallmos1 in forum New To Java
    Replies: 7
    Last Post: 11-24-2010, 09:22 PM
  2. Event Handling
    By zzpprk in forum AWT / Swing
    Replies: 2
    Last Post: 11-12-2009, 10:30 PM
  3. Event handling... help?
    By kevzspeare in forum New To Java
    Replies: 2
    Last Post: 04-04-2009, 09:46 PM
  4. Event handling in JSF
    By java08 in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 03-24-2009, 07:42 AM
  5. rmi and event handling
    By darkhorse in forum Advanced Java
    Replies: 0
    Last Post: 03-15-2009, 09:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •