Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: event does not occur

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default event does not occur

    <%@ 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>
    <table>
    <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()">
    <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" class="texta1" 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" class="texta1" 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>


  2. #2
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: event does not occur

    Quote Originally Posted by sukanya

    HTML Code:
    <%@ 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>
    <table>
    <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()">
    <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" class="texta1" 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" class="texta1" 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> 
    I cannot find a document.form out there. There is a document.forms that will return an array of the forms out there.

    Try document.forms[0] , assuming that that form is the first form you have, otherwise use the proper index, instead of document.form and see if it works then. Also, I can't find any form element called ltype. There is one called leavtype but no ltype. If you don't specify its correct name, it won't do anything. Assuming you meant leavtype and, the select object, it would be best to try this:

    var a =
    document.forms[0].leavtype.options[document.forms[0].leavtype.selectedIndex].value;

    That returns the value of the currently selected select object. (What it looked like you were doing is getting the value of the entire select object.)



    HTML DOM Document Object
    HTML DOM Select Object
    Last edited by javapenguin; April 7th, 2012 at 10:51 PM.

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: event does not occur

    Thanks for the relpy. I will try this solution.

Similar Threads

  1. Event Issues
    By fractalorbit in forum AWT / Java Swing
    Replies: 3
    Last Post: September 2nd, 2011, 07:49 PM
  2. [SOLVED] jTable event help
    By banny7 in forum AWT / Java Swing
    Replies: 12
    Last Post: August 1st, 2011, 07:42 AM
  3. Event Handling
    By maress in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 24th, 2011, 03:29 AM
  4. After a rowInserted() event!
    By MarkusHendersonicus in forum JDBC & Databases
    Replies: 1
    Last Post: December 20th, 2010, 12:55 PM
  5. Event handling
    By subhvi in forum AWT / Java Swing
    Replies: 3
    Last Post: August 26th, 2009, 11:20 AM