亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

(bio)}: AJAXpostІ(wn)}get](wn)} [ӡ(y)]

: hua9537    r(sh)g: 2011-06-06 12:28
(bio)}: AJAXpostІ(wn)}get](wn)}
Ҝy(c)ԇstatusreadyStateֵ{getʽֵsæô

(g)ļ£

1.text.php
  1. <html>
  2. <head>
  3. <script src="clienthint.js"></script>
  4. </head>
  5. <body>
  6. <form>
  7. First Name:
  8. <input type="text" id="txt1">
  9. <input type="button" value="Submit" onClick="showHint()">
  10. </form>
  11. <p>Suggestions: <span id="txtHint"></span></p>
  12. </body>
  13. </html>
(f)ƴa
2.clienthint.js
  1. var xmlHttp
  2. function showHint()
  3. {
  4. var str = document.getElementById("txt1").value;
  5. if (str.length==0)
  6.   {
  7.   document.getElementById("txtHint").innerHTML="";
  8.   return;
  9.   }
  10. xmlHttp=GetXmlHttpObject();
  11. if (xmlHttp==null)
  12.   {
  13.   alert ("Browser does not support HTTP Request");
  14.   return;
  15.   }
  16. var url="gethint.php";
  17. var content="qt="+str;
  18. content=content+"&sid="+Math.random();
  19. xmlHttp.open("POST",url,true);
  20. xmlHttp.onreadystatechange=stateChanged;
  21. xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  22. xmlHttp.send(content);
  23. }

  24. function stateChanged()
  25. {
  26. if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  27. {
  28. document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
  29. }
  30. }

  31. function GetXmlHttpObject()
  32. {
  33. var xmlHttp=null;
  34. try
  35. {
  36. // Firefox, Opera 8.0+, Safari
  37. xmlHttp=new XMLHttpRequest();
  38. }
  39. catch (e)
  40. {
  41. // Internet Explorer
  42. try
  43.   {
  44.   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  45.   }
  46. catch (e)
  47.   {
  48.   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  49.   }
  50. }
  51. return xmlHttp;
  52. }
(f)ƴa
3.gethint.php
  1. <?php
  2. // Fill up array with names
  3. $a[]="Anna";
  4. $a[]="Brittany";

  5. $q = $_POST["qt"];
  6. if (strlen($q) > 0)
  7. {
  8. $hint="";
  9. for($i=0; $i<count($a); $i++)
  10.   {
  11.   if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
  12.     {
  13.     if ($hint=="")
  14.       {
  15.       $hint=$a[$i];
  16.       }
  17.     else
  18.       {
  19.       $hint=$hint." , ".$a[$i];
  20.       }
  21.     }
  22.   }
  23. }
  24. else echo "q is empty!<br>";
  25. //Set output to "no suggestion" if no hint were found
  26. //or to the correct values
  27. if ($hint == "")
  28. {
  29. $response="no suggestion";
  30. }
  31. else
  32. {
  33. $response=$hint;
  34. }

  35. //output the response
  36. echo $response;
  37. echo " to ";
  38. echo $q;
  39. echo "<br>";
  40. ?>
(f)ƴa

: hua9537    r(sh)g: 2011-06-07 07:23

]픣




gӭR Chinaunix (http://72891.cn/) Powered by Discuz! X3.2