Note that there are some explanatory texts on larger screens.

plurals
  1. POonkeyup function only firing once
    primarykey
    data
    text
    <p>I need the onkeyup to fire more than once, but it seems to be only firing once!</p> <p>When I enter something into the input box, it searches, but then whenever I backspace and search something else, the div stay's the same..</p> <p>Here is my code:</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 = 'dam_search.php?dam_text=' + 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> <p>Here is dam_search.php</p> <pre><code>&lt;?php //connect to db stuff here if (isset($_GET['dam_text'])) { $dam = $_GET['dam_text']; getSuggest($text); } function getSuggest($text) { $sqlCommand = "SELECT `name` FROM `table1` WHERE `name` LIKE '%$dam_text%'"; $query = mysql_query($sqlCommand); $result_count = mysql_num_rows($query); while ($row = mysql_fetch_assoc($query)) { echo $row['name'].'&lt;br /&gt;'; } } ?&gt; </code></pre> <p>ALSO: I am wondering how I can put the return of the name's it has searched into a dropdown from the input box instead of into the div, so when I click on one of the names, it auto fills the input box.</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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