The Little Guy Posted January 12, 2010 Share Posted January 12, 2010 I have a text box drop down menu, and I want to be able to use the arrow keys to navigate the drop down (like Google suggest). The problem that I am having, is that pages with a scroll bar, scroll while using the arrow keys. Is there any way to disable that or have a workaround? Link to comment https://forums.phpfreaks.com/topic/188146-suggest-box-arrow-key-problem/ Share on other sites More sharing options...
trq Posted January 12, 2010 Share Posted January 12, 2010 You need to call focus() on the drop down element. Link to comment https://forums.phpfreaks.com/topic/188146-suggest-box-arrow-key-problem/#findComment-993303 Share on other sites More sharing options...
The Little Guy Posted January 12, 2010 Author Share Posted January 12, 2010 it works on a div? Link to comment https://forums.phpfreaks.com/topic/188146-suggest-box-arrow-key-problem/#findComment-993304 Share on other sites More sharing options...
trq Posted January 12, 2010 Share Posted January 12, 2010 You said your using a drop down. Post some relevant code. Link to comment https://forums.phpfreaks.com/topic/188146-suggest-box-arrow-key-problem/#findComment-993309 Share on other sites More sharing options...
The Little Guy Posted January 12, 2010 Author Share Posted January 12, 2010 Oh sorry, it is a custom drop down, like Google suggest. the drop down box is a div, and each item in the div is a label with a block style (see image attachment). this is in a function which can triggered by a key press from multiple sources // Some irrelevant code above here var unicode = e.keyCode ? e.keyCode : e.charCode if(unicode == 40){ selResult = selResult + 1; }else if(unicode == 38){ selResult = selResult - 1; } if(unicode == 40 || unicode == 38 || unicode == 13){ itemSel = true; var q = document.getElementById('q'); var h = document.getElementById('hiddenSuggestion'); q.blur(); h.focus(); var suggestLink = document.getElementsByTagName('label'); for(var i = 0;i<suggestLink.length;i++){ if(suggestLink[i].id == suggestLink[i].id.match(/^_[0-9]$/)){ suggestLink[i].setAttribute("class", "suggestLink"); } } var selecd = document.getElementById("_"+selResult); selecd.setAttribute("class", "suggestArrow"); if(unicode == 13){ searchQuestion(selecd.innerHTML); } } // Some irrelevant code below here I hope the above helps... [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/188146-suggest-box-arrow-key-problem/#findComment-993316 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.