Why isn't Javascript changing a variable with onChange?
<p>So this is my code, I am wondering why changeUp isn't sending an alert to me or setting the variable value:</p>

<pre><code>var selecteduname;
var xmlhttp;
function changeUp()
{
document.getElementById("useruname").onChange = function() {
    selecteduname = this.value;
    alert(selecteduname);
updateAdduser();
}


function loadXMLDoc()
{

if (window.XMLHttpRequest)
  {
 xmlhttp=new XMLHttpRequest();
}
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
}

function updateAdduser()
{loadXMLDoc();
xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
    {
    var json = xmlhttp.responseText;
    var fields = JSON.parse(json);
    Object.keys(fields).forEach(function (name) {
  var input = document.getElementsByName(name);
  input.value = fields[name];
});
}
}
xmlhttp.open("GET", "ajaxuseradd.psp?uname="+selecteduname, true);
xmlhttp.send();
}

&lt;/script&gt;
</code></pre>

<p>and</p>

<pre><code>&lt;form action="adduser.psp" method="get"&gt;
&lt;fieldset&gt;
    &lt;label for="uname"&gt;Username:&lt;/label&gt;
    &lt;select name="uname" id="useruname" onChange="changeUp();"&gt;
&lt;%
Blah blah blah Python Code to generate option values
%&gt;


&lt;%= options %&gt; //More Python code, this actually puts them into the select box

&lt;/select&gt;

&lt;/fieldset&gt;
&lt;fieldset&gt;
    &lt;label for="fname"&gt;First Name:&lt;/label&gt;
    &lt;input type="text" name="fname" /&gt;
&lt;/fieldset&gt;
&lt;fieldset&gt;
    &lt;label for="lname"&gt;Last Name:&lt;/label&gt;
    &lt;input type="text" name="lname" /&gt;
&lt;/fieldset&gt;
&lt;fieldset&gt;
    &lt;label for="email"&gt;Email:&lt;/label&gt;
    &lt;input type="text" name="email"&gt;
&lt;/fieldset&gt;
</code></pre>

<p></p>
