0

I'm creating an integer array like that

    my_array = new array(60);
    for(var i=0;i<6;i++){
        for(var j=0;j<10;j++){
            my_array[(i*10)+j] = (i.toString())+"."+(j.toString());
        }
    }

this should result in an array with

my_array[0] = 0.0

...

my_array[59] = 5.9

Now I want to use that list for an autocomplete

$( "#my_id" ).autocomplete({
   source: my_array
});

It does not work, though. Any ideas why?

3
  • what's the error in colsole btw? Commented May 9, 2014 at 11:21
  • you should write my_array = []; instead of my_array = new array(60); Commented May 9, 2014 at 11:24
  • @Rorschach: I'm getting array is not defined error... I'm such a fool. Just noticed that it should be new Array(100) instead of new array(100). Thus writing Array with the big A. Commented May 9, 2014 at 11:34

2 Answers 2

1

You should write my_array = []; instead of my_array = new array(60);

Working fiddle.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, this works aswell, but see my comment above, just had a spelling error...
1

this is working code tested on Fiddle:

var my_array = [];
    for(var i=0;i<6;i++){
        for(var j=0;j<10;j++){
            my_array[(i*10)+j] = (i.toString())+"."+(j.toString());
        }
    }

$(document).ready(function(){

 $( "#my_id" ).autocomplete({
   source: my_array
});

});

Fiddle Example

1 Comment

thanks, this works aswell, but see my comment above, just had a spelling error...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.