title: javascript auto fill text inputs based on drop down selection
body: <p>I'm having trouble with this... Hoping to auto fill the text input boxes in my form upon selection of the username from the dropdown. Users array comes from a mysql db. Not sure I have the javascript written correctly. First is my array which will just get called from db as $users. Thanks for looking.</p>
  
  <pre><code>&lt;?php 
      $users=array
      (
          "User" =&gt; array 
          (
              "0" =&gt; array
                              (
                              "id" =&gt; "6",
                              "username" =&gt; "bsmith",
                              "full_name" =&gt; "Buddy Smith"
                              ),
              "1" =&gt; array
                              (
                              "id" =&gt; "2",
                              "username" =&gt; "lsmith",
                              "full_name" =&gt; "Libbie Smith"
                              ),
              "2" =&gt; array
                              (
                              "id" =&gt; "4",
                              "username" =&gt; "asmith",
                              "full_name" =&gt; "Andy Smith"
                              ) 
          )
      )
  ?&gt;
  </code></pre>
  
  <p>then the javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var ids = new Array();
  var use = new Array();
  var ful = new Array();
      &lt;?php
          foreach($users as $key=&gt;$value) {
              echo "ids[" . $key . "] = '" . $value['User']['id'] . "';\n";
              echo "use[" . $key . "] = '" . $value['User']['username'] . "';\n";
              echo "ful[" . $key . "] = '" . $value['User']['full_name'] . "';\n";
          }
          ?&gt;
  
          function Choice() {
              x = document.getElementById("users");
              x.value = y.options[y.selectedIndex].text;
              document.getElementById("ids") = ids[y.selectedIndex];
              document.getElementById("use") = use[y.selectedIndex];
              document.getElementById("ful") = ful[y.selectedIndex];
             }
  
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>then my html:</p>
  
  <pre><code>&lt;form name="form1" method="post" action=""&gt;
  &lt;select name="users" onChange='Choice();'&gt;&lt;option&gt; &lt;/option&gt;
  &lt;?php
  foreach ($users as $key=&gt;$value) {
  echo '&lt;option value="'.$key.'"&gt;'.$value['User']['username'].'&lt;/option&gt;';
  }
  ?&gt;
  &lt;/select&gt;
  &lt;p&gt;&lt;input type="text" id="ids" name="id" &gt;&lt;/p&gt;
  &lt;p&gt;&lt;input type="text" id="ful" name="full_name" &gt;&lt;/p&gt;
  &lt;/form&gt;
  </code></pre>