I have the following php code that retrieves a list of items. I want to populate a listbox with the XMLHttpRequestO bject, but I am getting 1 long string instead of each item on a line. How can I populate the listbox correctly:
[code=php]
<?php
$dsn="Driver={S QL Server};Server= myserver;Databa se=mydb;";
$username="user ";
$password="pwd" ;
$sqlconnect=odb c_connect($dsn, $username,$pass word);
$sqlquery="SELE CT item, description
FROM db..tbl1 (nolock)
WHERE item LIKE '" . $_GET['q'] . "%'
OR description LIKE '%" . $_GET['q'] . "%'
AND item_status = 'A'";
$process=odbc_e xec($sqlconnect , $sqlquery);
while(odbc_fetc h_row($process) )
{
$item = odbc_result($pr ocess,"item");
$description = odbc_result($pr ocess,"descript ion");
$supdet = $item.' - '.$description;
echo $supdet;
}
odbc_close($sql connect);
?>
[/code]
My javascript code to handle the income responseText is:
[code=javascript]
function getList(dataSou rce)
{
xmlHttp=new ActiveXObject(" Microsoft.XMLHT TP");
xmlHttp.onready statechange=fun ction()
{
if(xmlHttp.read yState==4)
{
document.getEle mentById("autoL istResults").ad d(new Option (xmlHttp.respon seText, xmlHttp.respons eText));
document.getEle mentById("autoL istResults").st yle.visibility = "visible";
}
}
xmlHttp.open("G ET","server2.ph p?q=" + dataSource, true);
xmlHttp.send(nu ll);
}
[/code]
< Please use [code] tags when posting code! -Atli >
[code=php]
<?php
$dsn="Driver={S QL Server};Server= myserver;Databa se=mydb;";
$username="user ";
$password="pwd" ;
$sqlconnect=odb c_connect($dsn, $username,$pass word);
$sqlquery="SELE CT item, description
FROM db..tbl1 (nolock)
WHERE item LIKE '" . $_GET['q'] . "%'
OR description LIKE '%" . $_GET['q'] . "%'
AND item_status = 'A'";
$process=odbc_e xec($sqlconnect , $sqlquery);
while(odbc_fetc h_row($process) )
{
$item = odbc_result($pr ocess,"item");
$description = odbc_result($pr ocess,"descript ion");
$supdet = $item.' - '.$description;
echo $supdet;
}
odbc_close($sql connect);
?>
[/code]
My javascript code to handle the income responseText is:
[code=javascript]
function getList(dataSou rce)
{
xmlHttp=new ActiveXObject(" Microsoft.XMLHT TP");
xmlHttp.onready statechange=fun ction()
{
if(xmlHttp.read yState==4)
{
document.getEle mentById("autoL istResults").ad d(new Option (xmlHttp.respon seText, xmlHttp.respons eText));
document.getEle mentById("autoL istResults").st yle.visibility = "visible";
}
}
xmlHttp.open("G ET","server2.ph p?q=" + dataSource, true);
xmlHttp.send(nu ll);
}
[/code]
< Please use [code] tags when posting code! -Atli >
Comment