For autocomplete, I am using scripts from :
[url]http://momche.net/publish/article.php?page=acdropdown
To create the arrays, i have the following code block :
[code=php]
<?php
$fields = array();
$fields[“cl_name”]=array();
$fields[“codx”]=array();
$sql = mysql_query(“SELECT * FROM clients order by cl_name ASC”) or die(mysql_error());
while ($node = mysql_fetch_array($sql)) {
array_push($fields[“cl_name”], $node[“cl_name”]);
}
$sql = mysql_query(“SELECT * FROM produse order by cod ASC”) or die(mysql_error());
while ($node = mysql_fetch_array($sql)) {
array_push($fields[“codx”], $node[“cod”]);
}
?>
<script language=”JavaScript”>
var c_clname = new Array();
var a_codx = new Array();
<?php
for ($i=0; $i< count($fields[‘cl_name’]); $i++) {
echo ‘c_clname[‘.$i.’]= “‘. $fields[‘cl_name’][$i] .'”;’;}
for ($i=0; $i< count($fields[‘codx’]); $i++) {
echo ‘a_codx[‘.$i.’]= “‘. $fields[‘codx’][$i] .'”;’;}
?>
</script>
Here is my first autocomplete enabled input control for clients. It works pretty well
[code=html]
<input type=”text” id=”mstr_adi” name=”mstr_adi” autocomplete=”on” style=”width: 147px;” acdropdown=”true”
autocomplete_list=”array:c_clname” autocomplete_list_sort=”true” autocomplete_matchsubstring=”true” onblur=”print_client(this.value)”/>
And here is my second input control printed on the screen by AJAX :
[code=html]
<input type=”text” autocomplete=”on” id=”item_code” name=”item_code” style=”width: 77px; margin-left:2px” acdropdown=”false”
autocomplete_list=”array:a_codx” autocomplete_list_sort=”true” autocomplete_matchsubstring=”true” onblur=”get_item_name(this.value); get_item_price(this.value); get_set_adedi(this.value)”/>
It doesnt work. Possibly from the reason that array is not populated in the AJAX’s php file.
But anyway i dont have any concrete idea about the problem. What should i do to fix it?