Jump to content

Recommended Posts

Hi everyone, sorry for asking this question again, but this is something i am stuck, at the moment i am able to communicate with php ajax and display data using get method with some errors 'Parse error: syntax error, unexpected T_STRING in dropdownlist.php on line 11'

 

If someone just direct me to create a dropdown drill where on key press it populate a dropdown list to select the city and on select just close the dropdown list of cities.

 

Since I got addresses stored in database I thought to populate these addresses right below the address text input, than user just selects from the drop down list and the text field get updated with the city user selected.

 

I am stuck, any advise would be greatly appreciated.

 

thanks for reading.

 

Sorry here is my complete code:

 

 

<html>
<title>Drop Down Test</title>
<head>
... all other head stuff here ...

<script language="javascript">
<!--
function createSelect(allist){ 
var xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttpReq.open('get', 'dropdownlist.php?alist='+allist, false);
xmlHttpReq.send();
var response = xmlHttpReq.responseText;
document.getElementById('displayaddress').innerHTML = response;
}
//-->
</script>
</head>
<body>
Type Address:
<Input name="address" class="textbox" onkeyup="createSelect(this.value)">
<div id="displayaddress"></div>
</body>
</html>


<?PHP

    include_once('../config.php'); 
include_once('../opendb.php'); 
  
$sa=$_GET['allist']; 
     
    $Qrydata="SELECT id, name FROM clientsview WHERE name LIKE '$sa%'"; 
    $result=mysql_query($Qrydata) or die('Error, query failed'); 

$outdata= "<select name=\"ddaddress\">"; 
     
    while( $dlist = mysql_fetch_array($result) ) 
      $outdata.="<option value='".$dlist['id']."'>" .$dlist['name']."</option>"; 
     
    $optStr.="</select>";   
     
    echo $outdata; 
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.