0

Well, I have the really super simple stuff in jsfiddle. I am experimenting to make sure I can do it right in jquery first before I have to dynamically generate the jquery in C#. Basically the jQuery is suppose to populate an html based on values in an array.

You can view the fiddle here http://jsfiddle.net/KwVty/

This is what I have so far. But its not working.

var makes = new array();
makes[0] = 'HOONDA';
makes[1] = 'MEETSUBITCHE';
makes[2]=  'NEWSMOBILE';
makes[3]=  'FJORD';

for(var i=0; i<makes.length; i++)
 {   
     $('#2').append('<option value=1>'+makes[i]+'</option>');
 }

And in the HTML:

<select id="2" multiple="multiple">
    <option> 10</option>    
</select>
5
  • 1
    The option value is 1 in all cases. Replace /1/"+i+"/ Commented Jul 12, 2013 at 17:31
  • 2
    Array has an uppercase A, not a lowercase a. Commented Jul 12, 2013 at 17:32
  • 30 seconds too late you are :-P Commented Jul 12, 2013 at 17:33
  • 2
    Some advice, check your developer tools / console. You would've seen an error about array not being defined. Commented Jul 12, 2013 at 17:33
  • see my answer here: stackoverflow.com/questions/9995017/… Commented Jul 12, 2013 at 17:40

2 Answers 2

8

There is no such thing as array natively in javascript.

I think you meant to use new Array() (note the uppercase A) or []

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

4 Comments

there is also "array", which is the typeof []
@JanDvorak idk what browser you are using but in Chrome: typeof [] === "object"
ah, oops, sorry. Maybe in ES6 or ES7? :-)
Sorry about that. Been coding with very little sleep, been prone to little mistakes.
1

array(wrong) is declared as Array

 var makes = new Array();

Working Demo http://jsfiddle.net/KwVty/1/

Comments

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.