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 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









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
Null value when i set interface object in form controller - Spring
Null value when i set interface object in form controller   Hi all, i am very new about spring and hibernate. i got null value when i set interface object in form Controller. public void setOHBillManager(OHBillManager
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
java.lang.NumberFormatException: null
java.lang.NumberFormatException: null   I get org.apache.jasper.JasperException: java.lang.NumberFormatException: null exception when i submit the form plz help me regarding this..ADS_TO_REPLACE_1
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.ADS
javascript null mean
javascript null mean  What does javascript null mean
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
object of object class
object of object class  what do u mean by "object of object class
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 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
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
disallow NULL values in a table.
disallow NULL values in a table.  How do I disallow NULL values in a table
array_merge null - PHP
array_merge null   i am using the array_merge and getting the unusual null error...any help
Null pointer exception in hibernate - Hibernate
Null pointer exception in hibernate  Hi i am getting null pointer... is compiled successfully but while running the program i am getting null ponter exception. SessionFactory object is not creating pls give me the solution
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
What is NOT NULL Constraint?
What is NOT NULL Constraint?  What is NOT NULL Constraint?   Hi, The NOT NULL constraint enforces a column to NOT accept NULL values.The NOT NULL constraint enforces a field to always contain a value. This means
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... if the variable is not defined or null in PHP. and after setting a variable
comparison with null - Framework
comparison with null  String value = txtfld.getText(); if (value == null) ----- failing step----control goes to else part { // some code... friend, if (value == null) works properly for comparision For any more
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
Vector object[]
[] splitVal = (Object[])value; // cast to array of Object if (splitVal != null...; // cast to array of Object if (splitVal != null) { String...Vector object[]  I want to create payslip in java public Vector
SPEL-Wiring Null
will be as below: ------------------------------------- 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
comparison with null - Framework
comparison with null  I am having one textfield, from which I am getting text using getText() method. Now I want to compare this value with null (i.e. to check whether the entered value is null or not) How should I check
array_merge null - PHP
array_merge null   i am using the array_merge and getting the unusual null error...any help?  Hi Friend, Please visit the following links: http://www.roseindia.net/tutorial/php/phpbasics/PHP-Array-Merge
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
object 2 string - Java Beginners
object 2 string  hi sir,how to convert object to string and how 2 compare object with null value to string with null value plz provide a program 4 this sir,plzzzzzzzzz
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
PHP Null Variables
PHP Null Variables PHP Null variable is a type that only stores the null value. The Null value indicates that the used variable has no value. The variable only considered null when : 1. The variable assigned as a null.ADS_TO_REPLACE_1
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
object creation
object creation  when will java object is created? is it at runtime or compiletime
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
Object Oriented
Object Oriented  C++ is Purely object oriented or not .Then why java called purely object oriented
what is a null pointer exception in java
what is a null pointer exception in java  what is a null pointer exception in java
Object reference not set to an instance of an object
Object reference not set to an instance of an object  Object reference not set to an instance of an object

Ads