topical media & game development

talk show tell print

professional-ria-04-HelloWorldv5.htm / htm



  <!--
  Fifth version of HelloWorld.html
     
  This version adds:
    - Call to version 2 of the php. 
  -->
  <html>
    <head>
      <script type="text/javascript">
        var xmlRequest = new XMLHttpRequest();
  
        function handleCountryChange() {
          var countryValue = document.getElementById("country").value;
          var uri = "helloResponsev2.php?country=" + countryValue;
          xmlRequest.open("GET", uri, true);
          xmlRequest.onreadystatechange = helloCallback;
          xmlRequest.send(null);
        }
  
        function helloCallback() {
          if (xmlRequest.readyState == 4) {
            var messageL = document.getElementById("messageLabel")
            if (xmlRequest.status == 200) {
              messageL.innerHTML = xmlRequest.responseText
            } else {
              messageL.innerHTML = "Page Not Found"
            }
          }
        }
      </script>
    </head>
    <body>
      <form id="helloForm"><label>Say Hello: </label>
        <select id="country" onkeyup="handleCountryChange()" 
          onchange="handleCountryChange()">
          <option>France</option>
          <option>Germany</option>
          <option>Spain</option>
          <option>USA</option>
        </select>
      </form>
      <p/>
      <label id="messageLabel" style="border: thin solid"></label>
    </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.