facebook

Example of dynamically loading a combobox or select list?

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #331639 Reply

    Tom Niehoff
    Member

    Is there a recent example of dynamically loading a dropdown? I have done this with standard jquery and it doesn’t seem to work, like the following (not actual code, just example):

    var s= $(‘#mySelect’);
    s.options[s.options.length]= new Option(‘My option’, ‘1’);

    Thanks,

    Tom

    #331644 Reply

    Hi trn579s,

    Please try with the next code:

    $('select[name="combobox1"]').append(new Option("option 1","1") );
    #331746 Reply

    Tom Niehoff
    Member

    Thanks Octavio!

    Your method worked just fine, the issue was trying to call the element by element id instead of name:

        //works
        $('select[name="somecombo"]').append(new Option("option 1", "1"));
    
        //works
        $('select[name="somecombo"]').html("<option value='1'>Some oranges</option><option value='2'>More Oranges</option><option value='3'>Even more oranges</option>")
    
        //does not work
        $('#somescreenid-somecombo').html("<option value='3'>Some oranges2</option><option value='2'>More Oranges2</option><option value='3'>Even more oranges2</option>")

    While you can use JQuery #screenid-elementid for retrieving values, it seems you have to use the name= instead when inserting. Any idea why that would be the case?

    Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Example of dynamically loading a combobox or select list?

You must be logged in to post in the forum log in