I need to bind a java.util.List<String> to a HTML drop-down javascript.
I am able to get the java.util.List in the below format:
[Name1,Name2,Name3]
For binding I will use this code (it works fine):
var opt = document.createElement("OPTION");
opt.text = xhr.responseText;
opt.value = xhr.responseText;
document.getElementById("slctFullName").options.add(opt);
But I don't know the easiest approach to iterate through these elements.
Please let me know how to iterate through the elements :(
Thanks,
["Name1", "Name2", "Name3](notice the quotes), you can then parse then JSON and you have a javascript array.{"Name1":"Name1","Name2":"Name2","Name3":"Name3"}. I am able to get this in javascript. Now tell how to bind this JSON with the drop-down in javascript. I usedGsonin java servlet to generate this JSon. Thanks,