options select from array

Solutions on MaxInterview for options select from array by the best coders in the world

showing results for - "options select from array"
Ahmed
28 Apr 2020
1var states = new Array();
2states['India'] = new Array('Andhra Pradesh','Arunachal Pradesh','Assam','Bihar','Chhattisgarh','Goa','Gujarat','Haryana','Himachal Pradesh','Jammu and Kashmir','Jharkhand','Karnataka','Kerala','Madhya Pradesh','Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Odisha','Punjab','Rajasthan','Sikkim','Tamil Nadu','Telangana','Tripura','Uttar Pradesh','Uttarakhand','WestBengal','Andaman and Nicobar Islands','Chandigarh','Dadra and Nagar Haveli','Daman and Diu','Lakshadweep','Puducherry'); 
3
4function setStates() {
5	var newOptions=states['India'];
6	var newValues=states['India'];
7	selectField = document.getElementById("state");
8	selectField.options.length = 0;
9	for (i=0; i<newOptions.length; i++) 
10	{
11	selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
12	}
13}
Emely
15 Jul 2019
1var j = new Array("option1","option2","option3","option4","option5"),    
2var options = '';
3
4for (var i = 0; i < j.length; i++) {
5   options += '<option value="' + j[i]+ '">' + j[i] + '</option>';
6}
7$("#rec_mode").html(options);
8
Gwenaëlle
25 Feb 2018
1var videoSrcArr = new Array("option1","option2","option3","option4","option5"),
2    selectEl = document.getElementById('rec_mode');
3
4
5for(var i = 0; i < videoSrcArr.length; i++){
6    selectEl.options.add(new Option(videoSrcArr[i], videoSrcArr[i]));
7}                              
8
similar questions
queries leading to this page
options select from array