Results 1 to 3 of 3
  1. #1
    sukanya is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default event does not occur

    I am designing a leave request form.My logic is While selecting the leave type it goes to another form(eg: if marriage leave is selected it goes to marriage.jsp page).But it does not go to next page.
    Please anyone help to fix the problem.
    My code is below.

    <%@ page import="java.sql.*,databaseconnection.*"%>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script language="JavaScript">
    function validation()
    {
    var a = document.form.ltype.value;
    if(a=="Marriage Leave")
    {
    location.href="marriage.jsp";
    }
    else if(b=="Special Leave")
    {
    location.href="special.jsp"
    }
    }
    </script>
    </head>
    <body>
    <form name="form" action="empleaveinsert.jsp" method="post">
    <p align="right" height="37" class="paragraping">Type of Leave:
    <select name="leavtype" class="texta1" onblur="return validation()">//this event does not occur
    <option name="select1"><- - - SELECT - - - ></option>
    <option name="Casual Leave">Casual Leave</option>
    <option name="Privilege Leave">Privilege Leave</option>
    <option name="Marriage Leave">Marriage Leave</option>
    <option name="Maternity Leave">Maternity Leave</option>
    <option name="Special Leave">Special Leave</option>
    </select>
    </p>

    <%
    try
    {
    Connection con=databasecon.getconnection();
    Statement st=con.createStatement();
    String s=(String)session.getAttribute("staffcode");
    String sql="select * from staff where staffcode ='"+s+"'";
    ResultSet rs=st.executeQuery(sql);
    while(rs.next())
    {
    %>
    <table width="549">
    <tr>
    <td width="549" height="24" background="/images/img02.jpg"><font color="#FFFFFF" size="4">Applicant</font></td>
    </tr>
    </table>
    <table>
    <tr>
    <td height="37" class="paragraping">StaffCode</td>
    <td>&nbsp;&nbsp;&nbsp;<input name="name" TYPE="text" class="texta1" value="<%out.println(rs.getString("staffcode"));%> "></td>
    </tr>
    <tr>
    <td height="37" class="paragraping">Name</td>
    <td>&nbsp;&nbsp;&nbsp;<input name="name" TYPE="text" class="texta1" value="<%out.println(rs.getString("name"));%>"></td>
    </tr>
    <tr>
    <td height="37" class="paragraping">Designation</td>
    <td>&nbsp;&nbsp;&nbsp;<input name="designation" TYPE="text" value=" <%out.println(rs.getString("designation"));%>">
    </td>
    </tr>
    <tr>
    <td height="37" class="paragraping">Department</td>
    <td>&nbsp;&nbsp;&nbsp;<input name="department" TYPE="text" value="<%out.println(rs.getString("department"));% >"></td>
    </tr>
    <tr>
    <td height="37" class="paragraping">DOJ</td>
    <td>&nbsp;&nbsp;&nbsp;<input name="doj" TYPE="text" class="texta1" value="<%out.println(rs.getString("doj"));%>"></td>
    </tr>
    </table>
    </form>
    <%
    }
    st.close();
    con.close();
    }
    catch(Exception e)
    {
    out.println(e);
    }
    %>
    </body>
    </html>

    thanks in advance.
    Last edited by sukanya; 04-08-2012 at 04:26 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: event does not occur

    Look around the forum FAQs and discover how to post code so that it retains its formatting.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: event does not occur

    This is a Javascript question.
    Yes, you have Java in your JSP (which should be in a servlet), but the question is about your Javascript event.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Error occur while installing Eclipse
    By samantasmita in forum Eclipse
    Replies: 1
    Last Post: 01-05-2012, 02:24 PM
  2. Replies: 1
    Last Post: 07-19-2011, 04:20 PM
  3. checking for an event during an event
    By infinity in forum AWT / Swing
    Replies: 22
    Last Post: 04-09-2009, 01:08 AM
  4. Key event
    By ivvgangadhar in forum Threads and Synchronization
    Replies: 1
    Last Post: 12-11-2008, 09:27 AM
  5. Event
    By nt5515 in forum New To Java
    Replies: 0
    Last Post: 02-15-2008, 04:44 PM

Posting Permissions

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