0

How could i fill array of select with options using ajax:

<select name = "names[1]"></select>
<select name = "names[2]"></select>
<select name = "names[3]"></select>
<select name = "names[4]"></select>
<select name = "names[5]"></select>

note: thats just for example, but iwant it dynamic so i dont know how many of select i do have, but all of them will contain same options.

4
  • 1
    add what json you getting from server Commented Jun 21, 2014 at 11:58
  • @SridharR {176: Object, 177: Object} my broblem is how to get number of arrays that i have Commented Jun 21, 2014 at 12:13
  • what is Object contains Commented Jun 21, 2014 at 12:13
  • First Parse Json and check what you are getting. Commented Jun 21, 2014 at 12:30

1 Answer 1

1

use little bit of jquery here.

$(function(){
var jsonArray = []; //your json array. 
var html = "";
for(i=0;i<jsonArray.length;i++){
 html += "<select name="'+jsonArray.name[i]+'"></select>"
}

$("#locationId").append(html); //append your html where ever you want

})
Sign up to request clarification or add additional context in comments.

1 Comment

no, actualy i have one json returned, and want it to fill it in many select objects

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.