I need help with an assignment. Don't need the answer, just what is wrong with my code.
I need to create a init() function. Create a variable named allSelect that references elements in my document. For each item in the allSelect object collection, add an onchange event handler that runs loadLink() function.
Create loadLink() function. Create a variable sIndex that points to the index of the selection list. Then loads the web page requested.
<script type="text/javascript">
window.onload = init;
var allSelect;
var sIndex;
function init() {
var allSelect = document.getElementsByTagName("*");
for (var i = 0; i < allselect.length; i++) {
if (allselect[i].className == "optionLinks") allSelect.push(allSelect[i]);
}
}
allSelect[i].onchange = loadLink;
function loadLink(siteList) {
var sIndex = this.id + "optionLinks";
location.href = siteList.options[sIndex].value;
}
</script>