Hi,

In the follwoing code,siteIDs[i]can't got the i value which defined in for loop.

Can anyone help me?

            for (i=0; i<siteIDs.length;i++){
                $( "#sites" ).autocomplete({             
                    source: siteNames,
                    select: function() {$('#siteID').val(siteIDs[i])}    
                });
             }

what exactly is your problem? is it that i is not the correct value, or is it that siteIDs has the wrong value? perhaps the problem is that you did not declare i.

$( "#sites" ).each().autocomplete({ 
source: siteNames,
select: function() {$('#siteID').val('give it a value)} 
});

This is not tested but the idea is to use .each instead of a loop. I would have to see more code to do anything other than this guess.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.