Q: Javascript function not firing - body onload OK, so I have a page that has the following, the function creates a drop down populated with information as q15:
The below code fires when a user selects an option from the drop down q14:
onchange="configureDropDownLists(this,'q15')"

The same function is called when the page loads using the onload option:
<body onload="configureDropDownLists('q14','q15');check();">

These are the two functions used:
function configureDropDownLists(q14,q15) {

        if (langu.languag=='English'){
            var not = new Array('');
            var australia = new Array('Perth','Brisbane','Sydney (Frenchs Forrest)','Sydney (Auburn)','Melbourne','Adelaide','Auckland');
            }

        switch (q14.value) {
            case '':
                document.getElementById(q15).options.length = 0;
                for (i = 0; i < not.length; i++) {
                    createOption(document.getElementById(q15), not[i], not[i]);
                }
                break;
            case '1':
                document.getElementById(q15).options.length = 0;
                for (i = 0; i < australia.length; i++) {
                    createOption(document.getElementById(q15), australia[i], [i+1]);
                }
                break;

        }

    }

    function createOption(ddl, text, value) {
        var opt = document.createElement('option');
        opt.value = value;
        opt.text = text;

        ddl.options.add(opt);
    }

Finally, this messy code is in the header section of the page:
<script type="text/javascript">

window.results = ["<?php echo implode ('","', $results); ?>"];

</script>
<script type="text/javascript">
function selected(){
    var res = 'test';
    document.getElementById("test").value = res;
    alert(res);
}
</script>
<script type="text/javascript">
    var langu = {
        languag : '<?php echo $lang; ?>'
     }
    </script>
<script src="main.js" type="text/javascript"></script>
<script src="javascripts/scriptaculous.shrunk.js" type="text/javascript" charset="ISO-8859-1"></script>
<script src="javascripts/page2_validation.js" type="text/javascript"> </script>

The code fires correctly using the onchange call when a user selects q14.  In addition, on q14 there is PHP code that auto selects an option if the user has visited the page before - in this instance I want the function to run and create q15 when the page loads, hence I'm trying to use onload, however, I simply cannot get it to fire.
Any ideas and suggestions welcomed, please!
H.

A: "this" is referring to the select so you need to pass a select object
Do this instead of inline
window.onload=function() {
  configureDropDownLists(document.getElementById('q14'),'q15');
  check();
}


A: You have passed a string as q14 when you intended to pass an element.
Having said that, this would be a lot easier to debug if you gave us a jsfiddle.net workspace to tinker with.
