pingeyeg
asked on
Dropdown list is filling with too many values
I have developed a function called getSizes() that should grab all sizes based on the site and type of ad selected. Meaning, there will be a certain amount of sizes per type of ad per site. My issue is, each site has the same type of ad, therefore I'm getting sizes from each site based on that one type selected. Man, I hope that makes sense. Anyway, below is the code.
JS
function getSizes() {
var site = document.getElementById("specSite").value;
var type = document.getElementById("mediaType").value;
var xSite = xmlDoc.getElementsByTagName("site");
var xType = xmlDoc.getElementsByTagName("type");
var xSize = xmlDoc.getElementsByTagName("adsize");
for(var s=0; s<xSite.length; s++) {
if(site == xSite[s].attributes.getNamedItem("name").value) {
for(var t=0; t<xType.length; t++) {
if(type == xType[t].attributes.getNamedItem("name").value) {
for(var si=0; si<xSize.length; si++) {
document.getElementById("iSize").innerHTML += "<option value=" + xSize[si].attributes.getNamedItem("size").value + ">" + xSize[si].attributes.getNamedItem("size").value + "</option>";
}
}
break;
}
}
break;
}
}
XML
<sites>
<site name="SITE">
<adtypes>
<type name="Image">
<adsize size="300x250">
<initial>40</initial>
<polite>80</polite>
<duration>15</duration>
<fps>24</fps>
<filetype>gif</filetype>
<filetype>jpeg</filetype>
<filetype>png</filetype>
</adsize>
<adsize size="336x280">
<initial>40</initial>
<polite>80</polite>
<duration>15</duration>
<fps>24</fps>
<filetype>gif</filetype>
<filetype>jpeg</filetype>
<filetype>png</filetype>
</adsize>
<adsize size="300x600">
<initial>40</initial>
<polite>100</polite>
<duration>15</duration>
<fps>24</fps>
<filetype>gif</filetype>
<filetype>jpeg</filetype>
<filetype>png</filetype>
</adsize>
Hopefully you get the idea because there 2654 lines of code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
var xType = xmlDoc.getElementsByTagNam
I didn't know you could do that.
I keep on learning.