selectedIndex is returning "undefined" as value
<p>Forgive me if this is a stupid question; it's been many years since I've worked with javascript. This is actually javascript and html rendered via PHP in Joomla, but I've tried using the same code in a plain old local HTML file and I'm getting the same error. I have a select field with several options, and onchange I want to set the value of a text field to the value of the selected option. No matter which option I choose, the text field is being set to "undefined". Can anyone help me out? Here's the plain html code:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
function setPrefix(){
    var f = document.adminForm;
    f.prefix.value = f.editprefixes.selectedIndex.value;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;form name="adminForm"&gt;

&lt;select name="editprefixes" onchange="javascript:setPrefix()"&gt;
&lt;option value=1000&gt;1000&lt;/option&gt;
&lt;option value=1001&gt;1001&lt;/option&gt;
&lt;option value=1005&gt;1005&lt;/option&gt;
&lt;option value=1011&gt;1011&lt;/option&gt;
&lt;option value=1016&gt;1016&lt;/option&gt;
&lt;/select&gt;
&lt;br /&gt;

&lt;input type="text" name="prefix" value="" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
