ajax onkeyup

  • ultimate11
  • Student
  • Student
  • ultimate11
  • Posts: 86

Post 3+ Months Ago

Code: [ Select ]
<html>
 <head>
  <title>Sending Data to the Server</title>

  <script language = "javascript">
   var XMLHttpRequestObject = false;

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

   function getData(dataSource, divID)
   {
    if(XMLHttpRequestObject) {
     var obj = document.getElementById(divID);
     XMLHttpRequestObject.open("GET", dataSource);

     XMLHttpRequestObject.onreadystatechange = function()
     {
      if (XMLHttpRequestObject.readyState == 4 &&
       XMLHttpRequestObject.status == 200) {
        obj.innerHTML = XMLHttpRequestObject.responseText;
      }
     }

     XMLHttpRequestObject.send(null);
    }
   }
  </script>
 </head>

 <body>


  <form>
   <input type = "text" name="search"
    onkeyup = "getData('search2.php', 'targetDiv')">

  </form>

  <div id="targetDiv">
   <p>The fetched message will appear here.</p>
  </div>

 </body>
</html>
  1. <html>
  2.  <head>
  3.   <title>Sending Data to the Server</title>
  4.   <script language = "javascript">
  5.    var XMLHttpRequestObject = false;
  6.    if (window.XMLHttpRequest) {
  7.     XMLHttpRequestObject = new XMLHttpRequest();
  8.    } else if (window.ActiveXObject) {
  9.     XMLHttpRequestObject = new
  10.      ActiveXObject("Microsoft.XMLHTTP");
  11.    }
  12.    function getData(dataSource, divID)
  13.    {
  14.     if(XMLHttpRequestObject) {
  15.      var obj = document.getElementById(divID);
  16.      XMLHttpRequestObject.open("GET", dataSource);
  17.      XMLHttpRequestObject.onreadystatechange = function()
  18.      {
  19.       if (XMLHttpRequestObject.readyState == 4 &&
  20.        XMLHttpRequestObject.status == 200) {
  21.         obj.innerHTML = XMLHttpRequestObject.responseText;
  22.       }
  23.      }
  24.      XMLHttpRequestObject.send(null);
  25.     }
  26.    }
  27.   </script>
  28.  </head>
  29.  <body>
  30.   <form>
  31.    <input type = "text" name="search"
  32.     onkeyup = "getData('search2.php', 'targetDiv')">
  33.   </form>
  34.   <div id="targetDiv">
  35.    <p>The fetched message will appear here.</p>
  36.   </div>
  37.  </body>
  38. </html>

i need to send the value in other page..and bring it back below in form.
Code: [ Select ]
$key=$_GET['input'];
echo $key;
  1. $key=$_GET['input'];
  2. echo $key;
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 414

Post 3+ Months Ago

I know that this is an old post but in case you haven't figured it out by now. it dosen't seem like your sending any get variables at all

(Untested but something like this will help)
HTML Code: [ Select ]
<input type="text" name="search" onkeyup="getData('search2.php?input=' + this.value, 'targetDiv')">
 
  1. <input type="text" name="search" onkeyup="getData('search2.php?input=' + this.value, 'targetDiv')">
  2.  

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 62 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.