javascript - AJAX Search on 2 Elements -


i working on project using classic asp (not idea) , ajax uses access database pull data from. have following form:

<form action="" id="autocomplete-search">  <div class="simplesearch"> <label for="intesearch">start typing name</label> <input type="text" onkeyup="showcustomer(this.value)" id="intesearch" onfocus="disable_submit()"> </div> 

the javascript have @ top of page following:

function showcustomer(str) { // remove white space name entered on search screen str = str.replace(" ", ""); var xmlhttp;     if (str=="") { document.getelementbyid("txthint").innerhtml="no records found"; return;  } if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5     xmlhttp=new activexobject("microsoft.xmlhttp");   } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) {     document.getelementbyid("txthint").innerhtml=xmlhttp.responsetext;     } }     xmlhttp.open("get","get_customer.asp?q="+str,true);     xmlhttp.send(); } 

this links asp file:

<% response.expires=-1 dim name name = request.querystring("q") sql="select person.id, person.forename, person.surname, person.postid, person.extension, person.internal_extension, person.mobile,  person.room_number, job.id, job.name staff inner join posts on job.id = person.jobid (person.forename & person.surname '%" & name & "%') or job.name '%" & name & "%' set conn=server.createobject("adodb.connection") conn.provider="microsoft.jet.oledb.4.0" conn.open("e:\websites\directory\database.mdb") set rs=server.createobject("adodb.recordset") rs.open sql,conn response.write("<table>") response.write("<thead>") response.write("<tr>")  response.write("<th>forename</th>")  response.write("<th>surname</th>")  response.write("<th>extension</th>")  response.write("<th>internal ext.</th>")  response.write("<th>mobile</th>")  response.write("<th>room no.</th>")  response.write("<th></th>")  response.write("</tr>")  response.write("</thead>")  response.write("<tbody>")  while not rs.eof      response.write("<tr>")      response.write("<td>" & rs("forename") & "</td>")      response.write("<td>" & rs("surname") & "</td>")      response.write("<td>" & rs("extension") & "</td>")      response.write("<td>" & rs("internal_extension") & "</td>")      response.write("<td>" & rs("mobile") & "</td>")      response.write("<td>" & rs("room_number") & "</td>")       response.write("<td>" & rs("name") & "</td>")       response.write("<td><a href='index.asp?view=staffrecord&staffid=" & rs("id") & "'>record</a></td>")      response.write("</tr>") rs.movenext loop response.write("</tbody>") response.write("</table>") %> 

the problem works when pulling data 1 table. ajax seems hate join reason.

any ideas?

your query needs changed refer tables job , person

sql="select person.id, person.forename, person.surname, person.postid, person.extension, person.internal_extension, person.mobile,  person.room_number, job.id, job.name staff person inner join posts job on job.id = person.jobid ((person.forename '%' , person.surname '%' , name '%') or (job.name '%' , name '%'))"; 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -