Question

my first post at StackOverFlow ^_^ (So yeah, i'm a noob, be gentle)

I have searched and actually found several solutions to my question around the web, but for some reason none of them work for me.

So here it goes: I have a list item, and inside it multiple 'select' inputs, as such:

<li id="langlevels">
   <select id="encombobox"></select>
   <select id="frcombobox"></select>
   <select id="hecombobox"></select>
   <select id="rucombobox"></select>
   <select id="arcombobox"></select>
   <select id="otcombobox"></select>
</li>

Now what i'm trying to do is: Using jQuery, initialize all of the 'select' inputs to values I have in an array:

var lang_levels = new Array("Native Level", "Good Level", "Amateur Level");

The way i'm trying (to no avail) to do this is:

    //Initializing language levels combobox values
    $("#langlevels > select").each(function () {
        for(var i=0; i<lang_levels.length;++i)
        {
            addOption($(this), lang_levels[i], lang_levels[i]);
        }
        */

    });

NOTE: addOption() is a method I know to be working because I use it to initialize other, un-nested 'select' inputs.

I would very much appreciate your help!

Thanks in advance :)

Was it helpful?

Solution

OK Got it!

The only problem was this:

addOption($(this), lang_levels[i], lang_levels[i]);

was supposed to be this:

addOption(this, lang_levels[i], lang_levels[i]);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top