Jump to content

Suggest box arrow key problem


The Little Guy

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.