Link to home
Start Free TrialLog in
Avatar of pingeyeg
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.

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Justin Mathews
Justin Mathews

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pingeyeg
pingeyeg

ASKER

Sweet... so, in essence, one of the lines would read:

var xType = xmlDoc.getElementsByTagName("site").getElementsByTagName("type").value;

I didn't know you could do that.

I keep on learning.