title: $_GET JavaScript and AJAX...
body: <p>I am relatively new to PHP and I am (trying to) developing my first AJAX code...</p>
  
  <p>I am trying to pass an attribute from a select with several options, each option with its very own unique attribute "values" that is a String.</p>
  
  <p>The PHP file GETs the value and does something with it (for instance prints it out). And the generated file is then returned to my main HTML page.</p>
  
  <p>Here is the source code...</p>
  
  <p>Here is my <strong>javaScript</strong>:</p>
  
  <pre><code>function showUser(myElement) {
  
      var str = myElement.options[myElement.selectedIndex].getAttribute("values");
  
      if (str == "") {
          document.getElementById("myResponse").innerHTML = "";
          return;
      } else { 
          if (window.XMLHttpRequest) {
              // code for IE7+, Firefox, Chrome, Opera, Safari
              xmlhttp = new XMLHttpRequest();
          } else {
              // code for IE6, IE5
              xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          }
          xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
              document.getElementById("myResponse").innerHTML = xmlhttp.responseText;
              }
          }
          xmlhttp.open("GET","getuser.php?q="+encodeURIComponent(str),true);
          xmlhttp.send();
      }
  }
  </code></pre>
  
  <p>My <strong>HTML</strong> is as following:</p>
  
  <pre><code>&lt;form&gt;
  &lt;select name="users" onchange="showUser(this)"&gt;
    &lt;option values=""&gt;Select a person:&lt;/option&gt;
    &lt;option values="Rasmus Lerdorf"&gt;Creator of PHP&lt;/option&gt;
    &lt;option values="Linus Torvalds"&gt;Developed Linux&lt;/option&gt;
    &lt;option values="Dennis Ritchie"&gt;Developper of C&lt;/option&gt;
    &lt;/select&gt;
  &lt;/form&gt;
  &lt;br&gt;
  &lt;div id="myResponse"&gt;&lt;b&gt;Person info will be listed here...&lt;/b&gt;&lt;/div&gt;
  </code></pre>
  
  <p>My <strong>PHP</strong> is:</p>
  
  <pre><code>&lt;?php
  $q = intval($_GET['q']);
  echo $q;
  ?&gt;
  </code></pre>
  
  <p>I get 0 instead of the text string, what is wrong with my code?</p>