ajax+options is null or not an Object

Ads
 

ajax+options is null or not an Object

HI i have developed a simple ajax application contains two drop down lists and and one search button when i seleted a mangername from the popuated dropdwon list its dispalyed all the employee names on selection of the employee name and i kept search it should dispalay me the employee details when i click on search button its saying options is null or not an Obejct..

here im sending my code

select.jsp

<%@page import="java.sql.*"%>
 <html>
      <head>  
      <script language="javascript" type="text/javascript">  
      var xmlHttp  
      var xmlHttp
      function showEmp(str){
      if (typeof XMLHttpRequest != "undefined"){
      xmlHttp= new XMLHttpRequest();
      }
      else if (window.ActiveXObject){
      xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
      }
      if (xmlHttp==null){
      alert("Browser does not support XMLHTTP Request")
      return;
      } 
      var url="getemp.jsp";
      url +="?managername="+str;
      alert(url);
      xmlHttp.onreadystatechange = stateChange;
      xmlHttp.open("GET", url, true);
      xmlHttp.send(null);
      }

      function stateChange(){   
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
      document.getElementById("empname").innerHTML=xmlHttp.responseText

      }   
      }


      function searchDetails(){
          var combo = document.getElementsByName("empname");
         //alert(combo.options[combo.selectedIndex].text);
          var str = combo.options[combo.selectedIndex].value;

          alert("val of str is "+str);
          if (typeof XMLHttpRequest != "undefined"){
              xmlHttp= new XMLHttpRequest();
              }
              else if (window.ActiveXObject){
              xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
              }
              if (xmlHttp==null){
              alert("Browser does not support XMLHTTP Request")
              return;

              } 

          var url="check.jsp";
          url +="?count="+str;
          alert(str);
          xmlHttp.onreadystatechange = stateChange1;
          xmlHttp.open("GET", url, true);
          xmlHttp.send(null);
          }

          function stateChange1(){   
          if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
           document.getElementById("data").innerHTML=xmlHttp.responseText


                          }   
          }

      </script>  
      </head>  
      <body>  
      Select ManagerName:<select name='managername' onchange="showEmp(this.value)">  
       <option value="none">SelectManagername</option>  

    <%
 Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","hr");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from employee_table1");
 while(rs.next()){
     %>
      <option value="<%=rs.getString(3)%>"><%=rs.getString(3)%></option>  
      <%
 }
     %>
      </select>  

      <br>  
      <div id='empname'>  
      <select name='empname' >  
      <option value='-1'></option>  
      </select> 
           </div>  
       <input  type='button'   value= 'SearchforempDetails' onclick='searchDetails();' >
           <div id='data'>  
      <table name='data' >  
      </table>  
      </div>
      </body>
      </html>

getemp.jsp

<%@page import="java.sql.*"%>
<%
String managername=request.getParameter("managername");  
 String buffer="<select name='empname'><option value='-1'>SelectEmployeeName</option>";  
 try{
 Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","hr");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from employee_table1 where managername='"+managername+"' ");  
   while(rs.next()){
   buffer=buffer+"<option value='"+rs.getString(2)+"'>"+rs.getString(2)+"</option>";  
   }  
 buffer=buffer+"</select>";  
 response.getWriter().println(buffer); 
 }
 catch(Exception e){
     System.out.println(e);
 }

 %>

check.jsp

<%@page import="java.sql.*"%>
<%
String empname=request.getParameter("count");  
 String buffer="<table name='data'>";  
 try{
 Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","hr");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from employee_table1 where empname='"+empname+"' ");  
   while(rs.next()){
   buffer=buffer+"<tr><td>"+rs.getString("empcode")+"</td><td>"+rs.getString("org")+"</td></tr>";  
 }  
 buffer=buffer+"</table>";  
 response.getWriter().println(buffer); 
 }
 catch(Exception e){
     System.out.println(e);
 }
  %>
   <%=empname%>

Database table table name employee_table1;

and empcode, empname, managername, org are columns

Pls help me

Thanks in Adavace

View Answers

November 4, 2011 at 12:03 PM

hi Thanks,

I figured out the solution

Ads









Related Tutorials/Questions & Answers:
ajax+options is null or not an Object
ajax+options is null or not an Object  HI i have developed a simple ajax application contains two drop down lists and and one search button when i... dispalay me the employee details when i click on search button its saying options
ModuleNotFoundError: No module named 'null-object'
ModuleNotFoundError: No module named 'null-object'  Hi, My Python... 'null-object' How to remove the ModuleNotFoundError: No module named 'null-object' error? Thanks   Hi, In your python environment
Advertisements
object
object  is it possible to create object in the same class..?.   Yes, you can. class CreateObject { CreateObject(){ System.out.println("I have an object."); } public static void main(String[] args
null pointer
null pointer  dear sir , what is mean by null pointer in c
check null exception java
when we call or perform some action on the object or value when it null... if the object is null or assigned some value to it before performing action...check null exception java  check null exception java - How to check
null interface
null interface   what is the null interface and what is the use of it in real java project ?   Hi Friend, A null interface is an interface without any methods.Is also known as Marker interface. Null interfaces are used
Httpservletresponse null pointer exception.
Httpservletresponse null pointer exception.  What is Httpservletresponse null pointer exception?   NullPointerException occurs when we try to implement an application without referencing the object and allocating
Null Pointer Exception
Null Pointer Exception  whis is the Null Pointer Exception in java? or define Null Pointer Exception with exp?   NullPointerException occurs, when you try to implement an application without referencing the object
mysql query for null value
mysql query for null value   What mysql query for null value i need... { //echo message } To check if the object contain any value or not ..just compare it with zero. If the value for object is greater than zero display
Artifacts of null
List of Artifacts of null maven depenency
The null keyword
The null keyword       The null keyword in java programming language is a reserved word that is used... how to declare and define null values in java programming language
Java null pointer exception handling
: java.lang.NullPointerException occurs when it tries to invoke a null object, at the time...Java null pointer exception handling   What... program? Is this extends from exception class of Java?   Java null
null pointer exception in java
null pointer exception in java  What is null pointer exception in Java and when it occurs? Show it with an example.Thanks!   Java Null Pointer Exception
Null pointer execption
Null pointer execption  what is null pointer exception. I am getting the null pointer exception in this line conn= com.mypay.dao.Connection.getConnection(); what is wrong
Null pointer execption
Null pointer execption  what is null pointer exception. I am getting the null pointer exception in this line conn= com.mypay.dao.Connection.getConnection(); what is wrong
Java null pointer exception
Java null pointer exception  Hi I've made an array of Book objects... and a short summary. A Book object also contains the appropriate constructor...]!=null){ if(strfield.contains(param)){ result+=library[counter
ModuleNotFoundError: No module named 'null'
ModuleNotFoundError: No module named 'null'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'null' How to remove the ModuleNotFoundError: No module named 'null' error
if variable is null php
if variable is null php  How to check if submitted variable is null in PHP? Thanks!   Check if Variable is NULL in PHP You can use isset($var) to check if the variable is not defined or null in PHP. and after setting
Output of null value
main(String [] args){ String str=null; System.out.println(str); } } Output value Null Description:- In the given example... a String variable and initialized it with null value
SPEL-Wiring Null
: ------------------------------------- Person Object in MyClass: null...SpEL: Wiring Null Spring 3 provides powerful Expression Language which can be used to wire a property to null . Lets take an example to demonstrate how
Stumped with NOT NULL AUTO_INCREMENT
Stumped with NOT NULL AUTO_INCREMENT  I've almost made it through my... to create a new table with the ID column being NOT NULL AUTO_INCREMENT. The table will create if I do not have NOT NULL AUTO_INCREMENT, but it WILL NOT create
NULL POINTER EXCEPTION
NULL POINTER EXCEPTION    What is the Root cause for Class caste exception in struts frame work .and how 2 handle that 1 please help me
Server_Gives_Null_Response
Server_Gives_Null_Response   I have one InternetServer.java which starts a server at port 10000. In same class i have started a server at different...) to client class it always sends null and it shows NULL value only when i stop
org.apache.jasper.JasperException: java.lang.NumberFormatException: null
: null" exception. Also "The server encountered an internal error... con=null; int mobile=Integer.parseInt(request.getParameter("mobile
NUll POINTER EXCEPTION
NUll POINTER EXCEPTION  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException... of code i m getting null pointer Exception. can some one please explain what
Mysql Alter Allow Null
Mysql Alter Allow Null       Mysql Alter Allow Null is used to change the Null Type of a column in a table.The Allow Null allows the null type characteristics in a column
null pointer error
null pointer error  Respected sir there is a problem in this code when i add any new record in ms access data base from my code, it gives only null...(); setVisible(true); p.setSize(400,300); p.setBackground(Color.red); setLayout(null
null pointer error
null pointer error  Respected sir there is a problem in this code when i add any new record in ms access data base from my code, it gives only null...(); setVisible(true); p.setSize(400,300); p.setBackground(Color.red); setLayout(null
null pointer exceptions
null pointer exceptions  import java.util.*; public class employee { static int ch; static int emp[]; String name; int id,age; float sal; void insert() { employee[] emp=new employee[90]; Scanner r
null pointer exception in jsp
null pointer exception in jsp  index.html <html> <body> <table align=center> <form action="Login.jsp" method="get"> <tr> <td colspan=2><h1>Student Login</h1></td><
SQL NOT NULL Constraint
SQL NOT NULL Constraint       The NOT NULL constraint allows a column not to accept NULL values. This specify that NOT NULL Constraint enforce the field to accept a value

Ads