Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The original JS scripts as mentioned on Stack Overflow <https://stackoverflow.com/q/49040586/9217760>.
- [SCRIPT #1]
- /* Auto Suggestion */
- /*function insertAfter(newNode, referenceNode) {
- referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
- }
- var searchbar = document.getElementById("search_keywords");
- document.getElementById("search_keywords").onkeyup= function() {
- showResult(this.value);
- }
- var livesearch = document.createElement("div");
- livesearch.id = "livesearch";
- insertAfter(livesearch, searchbar);*/
- /* End of Auto Suggestion */
- [SCRIPT #2]
- <script>
- function showResult(str) {
- //Get category selection box
- var categoryBar = document.getElementById("search_categories");
- //Doctor
- if(categoryBar.options[categoryBar.selectedIndex].value == 88){
- if (str.length==0) {
- document.getElementById("livesearch").innerHTML="";
- document.getElementById("livesearch").style.border="0px";
- return;
- }
- if (window.XMLHttpRequest) {
- // code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- } else { // code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function() {
- if (this.readyState==4 && this.status==200) {
- document.getElementById("livesearch").innerHTML=this.responseText;
- document.getElementById("livesearch").style.border="1px solid #A5ACB2";
- }
- }
- xmlhttp.open("GET","livesearch_Doctor.php?q="+str,true);
- xmlhttp.send();
- }
- //Lawyer
- else if(categoryBar.options[categoryBar.selectedIndex].value == 89){
- if (str.length==0) {
- document.getElementById("livesearch").innerHTML="";
- document.getElementById("livesearch").style.border="0px";
- return;
- }
- if (window.XMLHttpRequest) {
- // code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- } else { // code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function() {
- if (this.readyState==4 && this.status==200) {
- document.getElementById("livesearch").innerHTML=this.responseText;
- document.getElementById("livesearch").style.border="1px solid #A5ACB2";
- }
- }
- xmlhttp.open("GET","livesearch_Lawyer.php?q="+str,true);
- xmlhttp.send();
- }
- //Mortgage
- else if(categoryBar.options[categoryBar.selectedIndex].value == 91){
- if (str.length==0) {
- document.getElementById("livesearch").innerHTML="";
- document.getElementById("livesearch").style.border="0px";
- return;
- }
- if (window.XMLHttpRequest) {
- // code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- } else { // code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function() {
- if (this.readyState==4 && this.status==200) {
- document.getElementById("livesearch").innerHTML=this.responseText;
- document.getElementById("livesearch").style.border="1px solid #A5ACB2";
- }
- }
- xmlhttp.open("GET","livesearch_Mortgage.php?q="+str,true);
- xmlhttp.send();
- }
- //Realtor
- else if(categoryBar.options[categoryBar.selectedIndex].value == 90){
- if (str.length==0) {
- document.getElementById("livesearch").innerHTML="";
- document.getElementById("livesearch").style.border="0px";
- return;
- }
- if (window.XMLHttpRequest) {
- // code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- } else { // code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function() {
- if (this.readyState==4 && this.status==200) {
- document.getElementById("livesearch").innerHTML=this.responseText;
- document.getElementById("livesearch").style.border="1px solid #A5ACB2";
- }
- }
- xmlhttp.open("GET","livesearch_Realtor.php?q="+str,true);
- xmlhttp.send();
- }
- //All categories
- else{
- if (str.length==0) {
- document.getElementById("livesearch").innerHTML="";
- document.getElementById("livesearch").style.border="0px";
- return;
- }
- if (window.XMLHttpRequest) {
- // code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- } else { // code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function() {
- if (this.readyState==4 && this.status==200) {
- document.getElementById("livesearch").innerHTML=this.responseText;
- document.getElementById("livesearch").style.border="1px solid #A5ACB2";
- }
- }
- xmlhttp.open("GET","livesearch.php?q="+str,true);
- xmlhttp.send();
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement