hello guys i have a simple problem the has me stumped. i really dont know what do do. I have a function like so.
function getThevalues(data) {
for (var i = 1; i < data.d.length; i++) {
MystartingLocation[i] = {}
MystartingLocation[i]["locName"] = {}
MystartingLocation[i]["locNode"] = {}
var Opts = document.createElement("option");
var Opt = document.createElement("opo");
MystartingLocation[i]["locNode"] = data.d[i].locNode;
MystartingLocation[i]["locName"] = data.d[i].locName;
Opts.text = data.d[i].locName;
//Opt.text = data.d[i].locName;
try {
document.getElementById("StartLocations").options.add(Opts);
document.getElementById("EndLocations").options.add(Opts);
}
catch (e) {console.log(e);}
}
}
I’m trying to fill both the start location and the endlocation drop down list with the same values yet every attempt that i have try only fills one of them the endlocation one. What I’m i doing wrong? can someone please point me in the right direction.
Thanks
Miguel
You can’t add the same element to both places in the document.
You need to either create two
optionelements or clone the one you have.Using two
optionelements would look like this: