PHP Classes

File: fwphp/glomodul/z_examples/AJAX_form_valid/Meloni/search.js

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/z_examples/AJAX_form_valid/Meloni/search.js   Download  
File: fwphp/glomodul/z_examples/AJAX_form_valid/Meloni/search.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/z_examples/AJAX_form_valid/Meloni/search.js
Date: 1 year ago
Size: 1,379 bytes
 

Contents

Class file image Download
// global variable to manage the timeout var t; // Start a timeout with each keypress function startSearch() { if (t) window.clearTimeout(t); t = window.setTimeout("liveSearch()",200); } // Perform the search function liveSearch() { // assemble the PHP filename query = document.getElementById("searchlive").value; filename = "search.php?query=" + query; // DisplayResults will handle the Ajax response ajaxCallback = displayResults; // Send the Ajax request ajaxRequest(filename); } // Display search results function displayResults() { // remove old list ul = document.getElementById("list"); div = document.getElementById("results"); div.removeChild(ul); // make a new list ul = document.createElement("ul"); ul.id="list"; names = ajaxreq.responseXML.getElementsByTagName("name"); for (i = 0; i < names.length; i++) { li = document.createElement("li"); name = names[i].firstChild.nodeValue; text = document.createTextNode(name); li.appendChild(text); ul.appendChild(li); } if (names.length==0) { li = document.createElement("li"); li.appendChild(document.createTextNode("No results")); ul.appendChild(li); } // display the new list div.appendChild(ul); } // set up event handler obj=document.getElementById("searchlive"); obj.onkeydown = startSearch;