Hiya Guys,
Been working on the w3schools livesearch example but you can only select the option via a link. I'm trying to do it so i can submit a value to return database results.
The external php code is below if anyone wants a look:
I got it returning the results from the xml file but the dropdown box appears under the text box so that value will not transfer into it.
I don't know if it's actually doable the way i'm trying because the results are returned into a <div id="txtupdate"></div> in the html page. Is there a way i can call the data into the html page without a predefined input box getting in the way?
cheers,
<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load("livesearch.xml");
$x=$xmlDoc->getElementsByTagName('link');
//get the q parameter from URL
$q=$_GET["q"];
//lookup all links from the xml file if length of q>0
if (strlen($q) > 0)
{
$hint="";
for($i=0; $i<($x->length); $i++)
{
$y=$x->item($i)->getElementsByTagName('title');
if ($y->item(0)->nodeType==1)
{
//find a link matching the search text
if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q))
{
if ($hint=="")
{
$hint="<option value='" . $y->item(0)->childNodes->item(0)->nodeValue. "'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</option>" . "<br />";
}
else
{
$hint=$hint . "<option value='" . $y->item(0)->childNodes->item(0)->nodeValue. "'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</option>" . "<br />";
}
}
}
}
}
// Set output to "no suggestion" if no hint were found
// or to the correct values
if ($hint == "")
{
$response="no suggestion";
}
else
{
$response=$hint;
}
//output the response
echo "<select name='Classification'>";
echo $response;
echo "</select>";
?>