Hi,i am trying to make this code work with the second textbox also,but its not working.Can anyone help?Its working with the first textbox.Please tell me what parameters to change?Thanks a lot.
-----------------------------------------------------------------------
[code]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Ajax Auto Suggest</title>
<script type="text/javascript" src="jquery-1.2.1.pack.js"></script>
<!--first text box-->
<script type="text/javascript">
function lookup(inputString)
{
if(inputString.length == 0)
{
// Hide the suggestion box.
$('#suggestions').hide();
}
else
{
$.post("rpc.php", {queryString: ""+inputString+""}, function(data)
{
if(data.length >0)
{
$('#suggestions').show();
$('#autoSuggestionsList').html(data);
}
});
}
} // lookup

function fill(thisValue) {
$('#inputString').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}
</script>

<!--second text box-->
<script type="text/javascript">
function lookup2(inputString2)
{
if(inputString2.length == 0)
{
// Hide the suggestion box.
$('#suggestions2').hide();
}
else
{
$.post("rpc2.php", {queryString: ""+inputString2+""}, function(data)
{
if(data.length >0)
{
$('#suggestions2').show();
$('#autoSuggestionsList2').html(data);
}
});
}
} // lookup

function fill2(thisValue) {
$('#inputString2').val(thisValue);
setTimeout("$('#suggestions2').hide();", 200);
}
</script>

<style type="text/css">
body {
font-family: Helvetica;
font-size: 11px;
color: #000;
}

h3 {
margin: 0px;
padding: 0px;
}

.suggestionsBox {
position: relative;
top: 35px;
left: 450px;
margin: 10px 0px 0px 0px;
width: 200px;
background-color: #323943;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border: 2px solid #000;
color: #fff;
}

.suggestionsBox2 {
position: relative;
top: 65px;
left: 450px;
margin: 10px 0px 0px 0px;
width: 200px;
background-color: #323943;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border: 2px solid #000;
color: #fff;
}

.suggestionList {
margin: 0px;
padding: 0px;
}

.suggestionList2 {
margin: 0px;
padding: 0px;
}

.suggestionList li {

margin: 0px 0px 3px 0px;
padding: 3px;
cursor: pointer;
}

.suggestionList li:hover {
background-color: #323943;
}
</style>

<meta name="generator" content="Web Page Maker">
<link rel="stylesheet" type="text/css" href="default.css" />
</head>
<body>
<form name="form1" style="margin:0px">

<input name="formtext1" type="text" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" style="position:absolute;width:200px;left:448px;top:29px;z-index:1">

<input name="formtext2" type="text" value="" id="inputString2" onkeyup="lookup2(this.value);" onblur="fill2();" style="position:absolute;width:200px;left:448px;top:73px;z-index:2">

</form>

<div class="suggestionsBox" id="suggestions" style="display: none;">
<!-- <img src="upArrow.png" style="position: relative; top: 31px; left: 450px;" alt="upArrow" /> -->
<div class="suggestionList" id="autoSuggestionsList">
&nbsp;
</div>

<div class="suggestionsBox2" id="suggestions2" style="display: none;">
<!-- <img src="upArrow.png" style="position: relative; top: 31px; left: 450px;" alt="upArrow" /> -->
<div class="suggestionList2" id="autoSuggestionsList2">
&nbsp;
</div>

<div id="text1" style="position:absolute; overflow:hidden; left:400px; top:31px; width:47px; height:21px; z-index:3">
<div class="wpmd">
<div><font face="Times New Roman">To:</font></div>
</div></div>

<div id="text2" style="position:absolute; overflow:hidden; left:401px; top:74px; width:47px; height:21px; z-index:4">
<div class="wpmd">
<div><font face="Times New Roman">From:</font></div>
</div></div>


</body>
</html>

[icode]


---------------------------------------------------------------------
php db code
[code]
<?php

// PHP5 Implementation - uses MySQLi.
// mysqli('localhost', 'yourUsername', 'yourPassword', 'yourDatabase');
$db = new mysqli("localhost", "root", "", "student");

if (!$db)
{
// Show error if we cannot connect.
echo 'ERROR: Could not connect to the database.';
}
else
{
// Is there a posted query string?
if (isset($_POST['queryString']))
{
$queryString = $db->real_escape_string($_POST['queryString']);

// Is the string length greater than 0?

if (strlen($queryString) > 0)
{
// Run the query: We use LIKE '$queryString%'
// The percentage sign is a wild-card, in my example of countries it works like this...
// $queryString = 'Uni';
// Returned data = 'United States, United Kindom';

// YOU NEED TO ALTER THE QUERY TO MATCH YOUR DATABASE.
// eg: SELECT yourColumnName FROM yourTable WHERE yourColumnName LIKE '$queryString%' LIMIT 10

$query = $db->query("SELECT first_name FROM info WHERE first_name LIKE '$queryString%' LIMIT 5");
if ($query)
{
// While there are results loop through them - fetching an Object (i like PHP5 btw!).
while ($result = $query->fetch_object())
{
// Format the results, i m using <li> for the list, you can change it.
// The onClick function fills the textbox with the result.

// YOU MUST CHANGE: $result->value to $result->your_colum
echo '<li onClick="fill(\'' . $result->first_name . '\');">' . $result->first_name . '</li>';
}
}
else
{
echo 'ERROR: There was a problem with the query.';
}
}
else
{
// Dont do anything.
} // There is a queryString.
}
else
{
echo 'There should be no direct access to this script!';
}
}

?>
[icode]