title: getting data from query sql database to javascript
body: <p>I have a problem with my code.<br>
  case like this:<br>
  I have a dropdown, if selected "personal" it appeared the new dropdown that contains the data that is retrieved from a database query, if selected "public", then the dropdown disappear.<br>
  HTML code like this:</p>
  
  <pre><code>&lt;select name="use" class="dropdown" id="sender" onChange='changeSend()'&gt;
       &lt;option value=1&gt;Public&lt;/option&gt;
       &lt;option value=0&gt;Personal&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;div id='send2'&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Query like this:</p>
  
  <pre><code>&lt;?php
      $query = mysql_query("select * from data where id_user = '$id_user' order by date asc");
      $i = 0;
      $id = array();
      $name = array();
      while($data = mysql_fetch_array($query)){
         //id from result database query
         $id[$i] = $data['id'];
         //name from result database query
         $name[$i] = $data['name'];
         $i++;
      }
  ?&gt;
  </code></pre>
  
  <p>JavaScript code like this:</p>
  
  <pre><code>function changeSend() {
     var selectBox = document.getElementById("sender");
     var selectedValue = selectBox.options[selectBox.selectedIndex].value;
     if (selectedValue==0) {
         $('#send2').html("&lt;select class='dropdown'&gt;&lt;option value='-id from result database-'&gt;-name from result database query-&lt;/option&gt;&lt;/select&gt;");
     } else { 
      $('#send2').html('');
     }
  }
  </code></pre>
  
  <p>I dont know how to send value/result <code>($id[0],$name[0],$id[1],$name[1], etc..)</code> to javascript code(value and name in select options).</p>