Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8514021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:44:48+00:00 2026-06-11T04:44:48+00:00

Through javascript how can I add more options to a dropdown selectmenu? Currently trying

  • 0

Through javascript how can I add more options to a dropdown selectmenu?

Currently trying the following with no luck:

for (i = 0; i < json.powerDropDownItems.length; i++) {
    //$('#powerSelect').append($("<option></option>").attr("value", json.powerDropDownItems[i]).text(json.powerDropDownItems[i]));
    $('#powerSelect').selectmenu("value", "nice name");
    //$('#powerSelect').appendTo("<option>" + json.powerDropDownItems[i] + "</option>");
}
$('#powerSelect').selectmenu("refresh");​

UPDATE

Thanks to naveen, I got it working (also added code to clear the list). Here is my following code:

 service.getPowerDropDowns(productEC, $('#mountSelect').val(), function (response) {
       var json = $.parseJSON(response.value);

       var options = [];

       // Clear the options first   
       $("#powerSelect option").each(function(index, option) {
            $(option).remove();
       });
        options.push("<option value=''>Choose</option>");
        for (i = 0; i < json.powerDropDownItems.length; i ++)
        {
            options.push("<option value='" + json.powerDropDownItems[i] + "'>" + json.powerDropDownItems[i] + "</option>");
        }
        $('#powerSelect').append(options.join("")).selectmenu();
        $('#powerSelect').selectmenu('enable');
    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:44:50+00:00Added an answer on June 11, 2026 at 4:44 am

    This will work

    $(function() {
        var options = []; 
        for (i = 0; i < json.powerDropDownItems.length; i++) {
            options.push("<option value='" + json.powerDropDownItems[i] + "'>" + json.powerDropDownItems[i] + "</option>");
        }
        //append after populating all options
        $('#powerSelect')
            .append(options.join(""))
            .selectmenu();
    });​
    

    Demo: http://jsfiddle.net/codovations/p863Q/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have a link with class=myClass1 While through Javascript, we can add
Possible Duplicate: Jquery Add Values to Select Options How can I empty a dropdown,
How can I loop through all members in a JavaScript object, including values that
Going through Javascript documentation, I found the following two functions on a Javascript object
I'm trying to extract a value through Javascript from an element's CSS3 attribute such
I have images on my page. User can add more images onto the page
I'm trying to achieve the following though with my intermediate JavaScript skills I'm not
I am trying to obtain the <RowDefinitions> element from my Xaml, through Javascript, so
Through JavaScript I am appending one query parameter to the page url and I
Is it possible through javascript to read the number from the iphone. Lets say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.