/    Sign up×
Community /Pin to ProfileBookmark

Autocomplete doesnt work in ajax fired control

For autocomplete, I am using scripts from :

[url]http://momche.net/publish/article.php?page=acdropdown[/url]

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>
[/code]

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)”/>
[/code]

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)”/>
[/code]

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?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@mrtbltauthorApr 03.2009 — any idea?
×

Success!

Help @mrtblt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...