Welcome to WebmasterWorld Guest from 54.162.12.134

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Auto Complete

     
3:15 am on Jun 18, 2012 (gmt 0)



Can u please help me to have some codes for "auto-complete" in text-box that gets the data from the database


Tnx :)
3:28 am on Jun 18, 2012 (gmt 0)

WebmasterWorld Senior Member leosghost is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



search "javascript auto-complete"
4:53 am on Jun 18, 2012 (gmt 0)



Is there a code for this in PHP. I need to write it in PHP form :)
3:54 pm on Jun 18, 2012 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You can put Javascript into PHP files, but auto complete is a function of the browser, not server side programming, and the only access to the browser itself is via client side scripting - as said, Javascript (or VBscript.)
12:52 pm on Jun 20, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<html>
<head>
<script type="text/javascript">
function findmatch() {
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('results').innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open('GET', 'search.inc.php?search_text='+document.search.search_text.value, true);
xmlhttp.send();
}
</head>
<body>
<form id="search" name="search">
Type a name:<br>
<input type="text" name="search_text" onkeyup="findmatch();">
</form>
<div id="results"></div>
</body>
</html>


****************search-inc.php**************

<?php

if (isset($_GET['search_text'])) {
echo $search_text = $_GET['search_text'];
}

if (!empty($search_text)) {

if (mysql_connect('localhost','root','')) {
id (mysql_connect_db('a_database')) {

$query = "SELECT `firstname` FROM `names` WHERE `name` LIKE '".mysql_real_escape_string($search_test)."%'";
$query_run = mysql_query($query);

while ($query_row = mysql_fetch_assoc($query_run))
echo $name = $query_row['name'].'<br>';

}
}
}

?>
5:53 pm on Jun 27, 2012 (gmt 0)

10+ Year Member



Here's a start [jqueryui.com...]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month