Jump to content

Suggest box arrow key problem


The Little Guy

Recommended Posts

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

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.