473,770 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I make the enter key select a combobox value?

1 New Member
I am using javascript to make a dropdownlist act like a combobox and it is work well. The issue I'm having is when the user types in the combobox and finds the selection he wants, he has to use the mouse to make the actual selection. The user wants to have the option of just hitting the enter key instead of using the mouse. He also wants to use the tab key to move to the next field. I'm using onkeydown to call the javascript, and I know I need to check for key code == 13 (for the enter key), but then what? How do I translate it into a select? I tried using document.getEle mentById("<%=Di rector.ClientID %>").click(); but the combobox just hung. Please help, someone.

<script language="javas cript">
var searchID;
var searchValue;

function checkKey(oList, e) {
// Re-initialize if the
if(oList.id != searchID) {
searchID = oList.id;
searchValue = "";
}

var theKey;
var binIE;
// check for browser event model
if(window.event ) { theKey = window.event.ke yCode; binIE = true; }
else { theKey = e.which; binIE = false; }

if(theKey == 8) { // check for backspace
searchValue = ""; // clear the filter
}
else if(theKey == 13) { // check for enter
return;
}
// check for alphanumeric keys and append to the search value
else if((theKey >= 48 && theKey <= 57) || (theKey >= 65 && theKey <= 90) ||
(theKey == 32) || (theKey >= 96 && theKey <= 105)) {
searchValue += String.fromChar Code(theKey).to LowerCase();
}
else { return false; }
// loop through the list to select the proper item
if(searchValue != "") {
for(var iCheck=0;iCheck <oList.options. length;iCheck++ ) {
if(oList.option s[iCheck].text.toLowerCa se().indexOf(se archValue) == 0) {
oList.options[iCheck].selected = true;
return;
}
}
}
}
</script>


<td align="left" width="25%">
<asp:DropDownLi st id="Director" onkeydown="chec kKey(this, event);return false;" runat="server"> </asp:DropDownLis t>
</td>
Feb 14 '08 #1
1 2192
nityaprashant
19 New Member
=============== ========Check in javascript===== ====
function captureEnterKey ()
{
if(event.keyCod e == 13)
{
// alert('keycode= ' + event.keyCode);
var a= document.getEle mentById("ctl00 _ContentPlaceHo lder1_UserContr olPanel1_btnGo" )
a.focus();
}
}
=============== =============== ===============


=============== ===Code Behind========= ==============
txtProductName. Attributes.Add( "onkeydown" , "if(event.w hich || event.keyCode){ if ((event.which == 13) ||(event.keyCod e == 13)){document.g etElementById(' " + btnGo.UniqueID + "').click();ret urnfalse;}} else {return true}; ")

ddlCategoryName .Attributes.Add ("onkeydown" , "if(event.w hich || event.keyCode){ if ((event.which == 13) ||(event.keyCod e == 13)){document.g etElementById(' " + btnGo.UniqueID + "').click();ret urnfalse;}} else {return true}; ")

ddlSubcategoryN ame.Attributes. Add("onkeydown" , "if(event.w hich || event.keyCode){ if ((event.which == 13) ||(event.keyCod e == 13)){document.g etElementById(' " + btnGo.UniqueID + "').click();ret urnfalse;}} else {return true}; ")

here ddlcategoryname & ddlsubcategory name is drop down list

=============== =============== ======
Feb 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3930
by: Programatix | last post by:
Hi, I'm having problem with ComboBox. I'm trying to force the ComboBox select nothing by doing this, myCombo.SelectedText = "" myCombo.SelectedIndex = -1 but in vain, as the ComboBox will automatically select the first available selection. If I make the ComboBox visible before setting the .SelectedText to "" and
2
3272
by: SAN CAZIANO | last post by:
check required in a select how can i control if a combobox (a select) is not null (index is -1) or if index is 0 if the first element is for example a null value or simply a description of the field . I try to use this if (combobox.SelectedIndex==0 || combobox.SelectedIndex==-1)
3
1536
by: RR | last post by:
What would the proper way be to enter a sale, then be able to enter 1 or more sales persons, their "costs" to the sale, and their commission on the sale? Then after its been entered, have all the information show up as a part of the sale?
8
3151
by: ShyGuy | last post by:
Is it possible to use code to enter some text into a combo box and then have the cursor placed at the end of the text for more imput?
1
8063
by: The.Daryl.Lu | last post by:
Hi, two parts to my problem if someone can help address either one or both: 1. I want to SELECT everything in the table if it matches the criteria when the query button is pressed (this is just a commandbutton on my form). The biggest problem I'm having is that I can't (don't know how) populate a combobox on static items such as "True, False, Any." The Any field, would be selected by the user to find all records where that fields is...
1
3236
by: billypit | last post by:
Hi, I am totaly new to MS Access. I have one form in MS Access in which i want that whenever i select an item from combobox then in the textbox on the same form or subform i want value from table based on selection from combobox. like in my table there two fields ID,name 1 billy 2 sandy
3
1786
by: BASSPU03 | last post by:
I had to present my DB today, but was granted a chance to fix something about it. In order to fix something, I added something...something that is giving me more trouble than it should. I have to present again tomorrow. Quick assistance would be greatly appreciated. I have three forms (one main form and two subforms) with the following fields: frmResultsFY FiscalYear sfrmResultsAgencies FiscalYear Agency
1
4253
by: Andrus | last post by:
I need to enter null value from combobox to business object property. My combobox datasource does not contain ValueMember with null value. So I tried to create combobox which stores null to bound object when text is deleted. However bound object contains old value in this case. To reproduce: 1. Run code
7
4893
by: creative1 | last post by:
hi, I have a simple query. I have a dynamic combobox when I select one value fromt he combobox; on click a function is called that display the value of the combobox(i.e not same as text list of combobox) in textbox on the form. I want to display the selected entry(not the value) of the combobox in another text box. How I can do that this is what I already have function getvalue(form) { ...
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9453
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.