Note that there are some explanatory texts on larger screens.

plurals
  1. POUL LI Selector - Why does this repeat several times with one press and does not function as expected?
    primarykey
    data
    text
    <p>When I kick start this function with one on key up, it repeats itself several times, and basically just does not work as expected.</p> <p><strong>What is expected?</strong></p> <p>For the handler to recognise my ul list and allow users to move up and down with a keyboard between li elements. Basically it forms part of an auto-complete function that I am working on, the list always brings the top 5 results depending on what the user inputs (data from php file via snippet of ajax/http request code).</p> <p>Does anyone have any ideas on what it could be? </p> <pre><code>document.getElementById("whatCountry").onkeyup = function () { showHint(this.value); document.addEventListener("keydown", handler); document.addEventListener("mouseover", handler); var active = document.querySelector(".hover") || document.querySelector(".the_results li"); function handler(e) { if (e.which == 40) { if (document.getElementById("these_results")) { active.classList.remove("hover"); if (e.which == 40) { active = active.nextElementSibling || active; //alert("something"); //document.getElementById("whatCountry").value= active.innerHTML; } else if (e.which == 38) { active = active.previousElementSibling || active; //alert("something else"); //document.getElementById("whatCountry").value= active.innerHTML; } else if (e.which == 9) { //alert("you pressed tab"); } else if (e.which == 13) { //alert("you pressed enter"); } else { active = e.target; //alert("exactly whatelse could happen"); }; active.classList.add("hover"); } } else { alert("The id is not existing so nothing should happen"); } }; }; </code></pre>
    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.
    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