Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Ajax how to display textbox value based on selected option value?

Have Programming Question? Ask it here!
 
 
 


k
how to display textbox value based on selected option value?
0 Answer(s)      3 years and a month ago
Posted in : Ajax


Hi,I have some problem. I use jsp and ajax.
first select: 1
second select:2 based on first value
 I finished above code.

ID: xx   Name:xx  xx is baesd on second and first value. But it is that l can't do that.


now, l post my code(not finished) here:
      function showdoc(id){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
 alert ("Browser does not support HTTP Request")
 return
 }
var url="/FYP/booking/getdocinfo.jsp"
url=url+"?doctor="+id
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    var showdata = xmlHttp.responseText;
    var strar = showdata.split(":");
      if(strar.length>1){
        var strname = strar[1];
        document.getElementById("doc_id").value= strar[1];
        document.getElementById("doc_name").value= strar[2];


         }
       }
     }


getdocinfo.jsp
<%@page language="java" import ="java.sql.*" %>
 <%
 Connection conn = null;
    String url = "jdbc:oracle:thin:@kk132.no-ip.org:1521:";
    String dbName = "XE";
    String driver = "oracle.jdbc.OracleDriver";
    String userName = "xx";
    String password = "xx";

 String doctor=request.getParameter("doctor").toString();
 String buffer="<tr><td>";
 Class.forName("oracle.jdbc.OracleDriver").newInstance();
 Connection con = DriverManager.getConnection(url+dbName,userName,password);
 Statement stmt = con.createStatement();
 String data="";
 ResultSet rs = stmt.executeQuery("Select * from DOCTOR where DOCTOR_ID='"+doctor+"'");
//out.print("<table border='1'>");
 //out.print("<tr><th>Employee ID</th>");
 //out.print("<th>Employee Name</th>");
//out.print("<th>Date</th>");
//out.print("<th>Time</th></tr>");
   while(rs.next()){

   data = ":" +rs.getString("DOCTOR_ID") +":"+ rs.getString("DOCTOR_NAME");

   }
 //buffer=buffer+"</td></tr></table>";
 System.out.println(data);
  //response.getWriter().println(data);


 %>
so, hope you help me. thanks

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com