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])}    
                });
             }

Recommended Answers

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.

Jump to Post

All 2 Replies

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 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.