troubleshooting Question

Cleaning Up An Array

Avatar of David Schure
David Schure asked on
9 Comments1 Solution18 ViewsLast Modified:
I am trying to clean this array up by removing the [""] tags.  Every time I do the code breaks.
There are two select boxes.  First one chooses the region, "United States", "India",etc.  Then the next one chooses the "State", etc.

	var stateObject = {
	"India": {"Delhi": ["", ""],"Kerala": ["", ""],"Goa": ["", ""],},
	"United States": {"Alabama": [""],"Alaska": [""],"Idaho": [""],},
	"Australia": {"South Australia": [""],"Victoria": [""]},
	"Canada": {"Alberta": [""],"Columbia": [""]},
	window.onload = function () {
	var countySel = document.getElementById("countySel"),
	stateSel = document.getElementById("stateSel")
	for (var country in stateObject) {
	countySel.options[countySel.options.length] = new Option(country, country);
	countySel.onchange = function () {
	stateSel.length = 1;
	if (this.selectedIndex < 1) return;
	for (var state in stateObject[this.value]) {
	stateSel.options[stateSel.options.length] = new Option(state, state);

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros