Member Avatar for Ralphael

I want my code yo retreive an xml file and display it as an options list under a select object but the code in google chrome is giving this error "Uncaught TypeError: Cannot read property '0' of undefined" and i dont know what to do about it please can someone help me.

 <script type="text/ecmascript">
        var oreofe;

        var xmlHttpDoc = new XMLHttpRequest();
             function loadWing()
            {
                var build = document.getElementsByName('building').item().value;
                alert(build);
                    if(xmlHttpDoc)
                    {
                        xmlHttpDoc.open("GET", "test.php?ret=build", true);
                        xmlHttpDoc.onreadystatechange = function()
                        {
                              if(xmlHttpDoc.readyState==4 && xmlHttpDoc.status==200)
                              {
                                  var xmlDocument;
                                  xmlDocument = xmlHttpDoc.responseXML;
                                  oreofe = xmlDocument.getElementsByTagName('option');
                                  listOptions();
                              }
                        }
                        xmlHttpDoc.send(null);
                    }               
            }

             function listOptions()
            {
              var loopIndex;
                    for (loopIndex = 0; loopIndex < oreofe.length; loopIndex++ )
                    {
                        document.getElementsByName('wing').options[loopIndex].v = new Option(oreofe[loopIndex].firstChild.data);
                    }
            }
        </script>


        this is the html part

         <p><label>Problem Location Building</label></p>
                        <p><select name="building" onchange="loadWing()"><option value="daniel">Daniel Hall</option><option value="john">John Hall</option><option value="esther">Esther Hall</option><option value="deborah">Deborah Hall</option></select></p>
                        <p><label>Problem Location Wing</label></p>
                        <p><select name="wing" ><option>Select a scheme</option></select></p>
Member Avatar for Ralphael

Why is any body not helping me I really need this for my FInal year Project

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.