How can I populate a select list with the Facilities listed in the following xml file:
<HealthServices>
<Divisions>
<Division>Home Office</Division>
<Facility>Administration</Facility>
<Facility>Finance</Facility>
<Facility>Human Resources</Facility>
<Facility>Operations</Facility>
</Divisions>
<Divisions>
<Division>Hospital</Division>
<Facility>Facility1</Facility>
<Facility>Facility2</Facility>
</Divisions>
<Divisions>
<Division>Sr. Housing</Division>
<Facility>Facility3</Facility>
<Facility>Facility4</Facility>
</Divisions>
</HealthServices>
I have one select list populated with the divisions using the following function:
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
//var allRoleListing;
var allDivisions;
var allDivisionNodes;
var allFacilityNodes;
function init(){
xmlDoc.async = false;
xmlDoc.load("./xml/esf_data4.xml");
//allRoleListing = xmlDoc.selectNodes("/IndividualListing");
allDivisions = xmlDoc.selectNodes("//Divisions");
allDivisionNodes = xmlDoc.selectNodes("//Division");
allFacilityNodes = xmlDoc.selectNodes("//Facility");
populateDivisionList();
populateFacilityList();
}
function populateDivisionList(){
clearSelect('OBDataset_Division_1');
var lstDivision = document.getElementById('OBDataset_Division_1');
for (var i=0; i<allDivisions.length; i++) {
var thisDivisionNameTxt = allDivisions.selectNodes("./Division")[0].text;
var newOption = document.createElement("option");
newOption.innerHTML=thisDivisionNameTxt;
newOption.value = allDivisions.selectNodes("./Division")[0].text;
lstDivision.appendChild(newOption);
}
document.getElementById('nTest2').innerHTML=allFacilityNodes.length;
}
This gets me all the facilities in the first Division node, but errors because the length of allFacilityNodes counts all the facility nodes in the file and I just want to count the ones in the first Division node or second,ect., depending what was selected in the Division list. Does anyone know how to fix this?
<HealthServices>
<Divisions>
<Division>Home Office</Division>
<Facility>Administration</Facility>
<Facility>Finance</Facility>
<Facility>Human Resources</Facility>
<Facility>Operations</Facility>
</Divisions>
<Divisions>
<Division>Hospital</Division>
<Facility>Facility1</Facility>
<Facility>Facility2</Facility>
</Divisions>
<Divisions>
<Division>Sr. Housing</Division>
<Facility>Facility3</Facility>
<Facility>Facility4</Facility>
</Divisions>
</HealthServices>
I have one select list populated with the divisions using the following function:
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
//var allRoleListing;
var allDivisions;
var allDivisionNodes;
var allFacilityNodes;
function init(){
xmlDoc.async = false;
xmlDoc.load("./xml/esf_data4.xml");
//allRoleListing = xmlDoc.selectNodes("/IndividualListing");
allDivisions = xmlDoc.selectNodes("//Divisions");
allDivisionNodes = xmlDoc.selectNodes("//Division");
allFacilityNodes = xmlDoc.selectNodes("//Facility");
populateDivisionList();
populateFacilityList();
}
function populateDivisionList(){
clearSelect('OBDataset_Division_1');
var lstDivision = document.getElementById('OBDataset_Division_1');
for (var i=0; i<allDivisions.length; i++) {
var thisDivisionNameTxt = allDivisions.selectNodes("./Division")[0].text;
var newOption = document.createElement("option");
newOption.innerHTML=thisDivisionNameTxt;
newOption.value = allDivisions.selectNodes("./Division")[0].text;
lstDivision.appendChild(newOption);
}
document.getElementById('nTest2').innerHTML=allFacilityNodes.length;
}
This gets me all the facilities in the first Division node, but errors because the length of allFacilityNodes counts all the facility nodes in the file and I just want to count the ones in the first Division node or second,ect., depending what was selected in the Division list. Does anyone know how to fix this?