selectedIndex in an onload function
Posted: Wed Jul 14, 2010 8:42 am
Javascript newbie here, rather confused...
I'm converting an old executable program into a web-based program, and have a dialog where various options depend on other options. I can set two select lists' selected indexes to the be the same based on an onchange. This works fine.
What I don't seem to be able to do is set selectedIndex in the javascript function which is called in onload. I can see the function gets called - it'll pop up an alert perfectly happily. But the selectedIndex line after it is simply ignored. (It was more complex than this - it was reading the value from somewhere else - but it fails no matter how simple I make it).
and then
I missed something really basic, right? Am I not allowed to use selectedIndex in an onload function? Or can someone point me at a five line example which works to start from?
I'm converting an old executable program into a web-based program, and have a dialog where various options depend on other options. I can set two select lists' selected indexes to the be the same based on an onchange. This works fine.
What I don't seem to be able to do is set selectedIndex in the javascript function which is called in onload. I can see the function gets called - it'll pop up an alert perfectly happily. But the selectedIndex line after it is simply ignored. (It was more complex than this - it was reading the value from somewhere else - but it fails no matter how simple I make it).
Code: Select all
function load(form)
{
form.mv.options.selectedIndex=1;
}
Code: Select all
<body onload='load(this.form)'>