Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>OnKeyUp will only fire once per event. pressing 'A' 'B' and 'C' will result in three calls to suggest1();</p> <p>To make sure your browser is working correctly try this</p> <pre><code> &lt;script type="text/javascript"&gt; function suggest1() { document.getElementById('myDiv').innerHTML = document.getElementById('dam').value; } &lt;/script&gt; &lt;input type="text" name="dam" id="dam" onkeyup="suggest1();"&gt;&lt;br /&gt; &lt;div id="myDiv"&gt;&lt;/div&gt; </code></pre> <p>You should see the div change for every keystroke that occurs in the input. </p> <p>There is two many unknowns for me to directly point at your actual issue. Your PHP will output nothing for a zero entry query, and will only output 1 item if you query LIKE only matches one thing. I think your problem lies elsewhere, an not with onkeyup</p> <p>T test to onkeyup on your system/browser: Try adding some debug header like <code>echo strlen($text).'&lt;br /&gt;';</code> to your PHP file. You should see the number change with out relying on your SQL query for every key press that adds or deletes text (that includes the backspace key). </p> <p>Your code looks fine. And runs fine for me using the public HTTP GET echo service at <a href="http://ivanzuzak.info/urlecho/" rel="nofollow">http://ivanzuzak.info/urlecho/</a></p> <p>Swapping out your PHP for the echo service works fine (with a bit of a typing delay)</p> <pre><code>&lt;script type="text/javascript"&gt; function suggest1() { var dam_text = document.getElementById('dam').value; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject('MicrosoftXMLHTTP'); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { document.getElementById('myDiv').innerHTML = xmlhttp.responseText; } } var target = 'http://urlecho.appspot.com/echo?body=' + dam_text; xmlhttp.open('GET', target, true); xmlhttp.send(); } &lt;/script&gt; &lt;input type="text" name="dam" id="dam" onkeyup="suggest1();"&gt;&lt;br /&gt; &lt;div id="myDiv"&gt;&lt;/div&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload