in Education by
I have dropdown in my form which has a CSS style defined on pageload and is hidden and the code is like
Run code snippetExpand snippet I am able to successfully append the options to this drop down, however they get inserted to a drop down without my CSS style as shown in the below image After the data is added to drop down the HTML looks like Run code snippetExpand snippet and the JQuery code looks like and the targetdropdown value would be "City" here and the Id and values appropriately $("div#City").toggle(); $('select[name="'+targetdropdown+'"]').empty(); jQuery('select[name="'+targetdropdown+'"]'). append(' --Select '+targetdropdown+'-- '); $.each(res[0],function(index, element) { var newOption = ''+element.Name+' '; jQuery('select[name="'+targetdropdown+'"]'). append(newOption); }); Can you please help me resolve the data being inserted to CSS styled drop down which is empty as you can see in the image JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
It seems you are using SelectBoxIt jQuery plugin for Custom styled dropdown list. When you done adding dynamic option to your div call .refresh() method. Add below line at the end of your javascript code. $('select[name="'+targetdropdown+'"]').data("selectBox-selectBoxIt").refresh();

Related questions

0 votes
    Please take a look at the following code... $("#page_info_select_box").live("keypress",function(){ var sele = "domain"; var inp ... :sele},function(data){ //alert(data); for (i=0;i...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
0 votes
    I'm builtin an web resume-generator to learn how to develop for web. I've made a HTML form which ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I'm builtin an web resume-generator to learn how to develop for web. I've made a HTML form which ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I have a background image on top of which there is some text. It is very hard to read the text ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I want to calculate browser height without considering browser address bar and bottom navigation bar height. The ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I want to calculate browser height without considering browser address bar and bottom navigation bar height. The ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    How can I replace a specific text with HTML objects? example: var text = "some text to replace ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    How can I replace a specific text with HTML objects? example: var text = "some text to replace ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Is there an 'official' way to get all input elements of a form including those outside of the form ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I've got an output from an API call as a list: out = client.phrase_this(phrase='ciao', database= ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I've got an output from an API call as a list: out = client.phrase_this(phrase='ciao', database= ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
...