473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Drop down behavior

I have two pages on one if focus is on the drop down that has numbers from 0
to 10 (select html) and user presses a number, element shows next matching
number. In an other page it seems to be the same generated html (different
css) and client side behavior of the element changes - it only changes if
user presses next number meaning if box shows 1 and user presses 2 then box
shows 2 but if user presses anything else nothing changes.
I don't know if this is correct news group but may be some one can give me
clues of direct me to the right place.
Thanks,
Shimon.
Nov 17 '05 #1
4 1259
Hi Shimon,

According to your description, I am not sure about what concern you have.
However, it seems that you are encountering some issues while working with
the autocomplete functionality of a comboBox. If it is the case, I have
written a simple sample for your reference. Here is the entire sample code.

<HTML>
<HEAD>
<TITLE>New Document</TITLE>

<SCRIPT language="JavaScript">
var searchString='';
var searchTimer=-1;

function onKey()
{
var i;
var j;
var eltOpt;
var elt=event.srcElement;
if (searchTimer!=-1)
clearTimeout(searchTimer);
switch (event.keyCode)
{
case 8: alert(event.keyCode); searchString=searchString.substr(0,
searchString.length-1); break;
case 13: //document.frmTOP.submit(); break;
default: searchString+=unescape("%"+event.keyCode.toString( 16));
}
j=elt.options.length;
for (i=0; i<j; i++)
{
eltOpt=elt.options(i);
if (eltOpt.text.toUpperCase().substr(0,
searchString.length)==searchString.toUpperCase())
{
eltOpt.selected=true;
break;
}
}
searchTimer=setTimeout('clearSearchString();', 1000);
event.returnValue=false;
}

function clearSearchString()
{
searchTimer=-1;
searchString='';
}
</SCRIPT>

</HEAD>

<BODY>
<form name=frmTOP method=post>

<select id=test onkeypress="onKey();" onfocus="clearSearchString();"
onchange="//document.frmTOP.submit();">
<option value=1>Gary</option>
<option value=1>Miranda</option>
<option value=1>Love</option>
<option value=1>Lost</option>
</select>

</form>
</BODY>
</HTML>

In my sample, if the current focus was on commoBox and we type "l",
followed by "os", the last item "Lost" will be selected. If we type "l",
followed by "ov", the third item, "love" should be selected.

Please let me know if it is what you are looking for.

Best regards

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #2
Thanks you for the answer
I hope it will help. I just personally think that I stumbled over some kink
of bug in the browser. It seems that this is a problem only in IE 6. In VS
browser it works just fine. Some other Drop downs on the page also work. In
Netscape it works but kind of strange (skipping few key strokes in a time).
Just the hole thing is very strange to me.
Also.
How do I add JavaScript handle to Web Control (I have ASP:DropDownList)?
Shimon.

"Jacob Yang [MSFT]" <ji***@online.microsoft.com> wrote in message
news:vR**************@cpmsftngxa06.phx.gbl...
Hi Shimon,

According to your description, I am not sure about what concern you have.
However, it seems that you are encountering some issues while working with
the autocomplete functionality of a comboBox. If it is the case, I have
written a simple sample for your reference. Here is the entire sample code.
<HTML>
<HEAD>
<TITLE>New Document</TITLE>

<SCRIPT language="JavaScript">
var searchString='';
var searchTimer=-1;

function onKey()
{
var i;
var j;
var eltOpt;
var elt=event.srcElement;
if (searchTimer!=-1)
clearTimeout(searchTimer);
switch (event.keyCode)
{
case 8: alert(event.keyCode); searchString=searchString.substr(0,
searchString.length-1); break;
case 13: //document.frmTOP.submit(); break;
default: searchString+=unescape("%"+event.keyCode.toString( 16));
}
j=elt.options.length;
for (i=0; i<j; i++)
{
eltOpt=elt.options(i);
if (eltOpt.text.toUpperCase().substr(0,
searchString.length)==searchString.toUpperCase())
{
eltOpt.selected=true;
break;
}
}
searchTimer=setTimeout('clearSearchString();', 1000);
event.returnValue=false;
}

function clearSearchString()
{
searchTimer=-1;
searchString='';
}
</SCRIPT>

</HEAD>

<BODY>
<form name=frmTOP method=post>

<select id=test onkeypress="onKey();" onfocus="clearSearchString();"
onchange="//document.frmTOP.submit();">
<option value=1>Gary</option>
<option value=1>Miranda</option>
<option value=1>Love</option>
<option value=1>Lost</option>
</select>

</form>
</BODY>
</HTML>

In my sample, if the current focus was on commoBox and we type "l",
followed by "os", the last item "Lost" will be selected. If we type "l",
followed by "ov", the third item, "love" should be selected.

Please let me know if it is what you are looking for.

Best regards

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #3
Hi Shimon,

Have you tried the sample code in my previous reply? The sample code was
tested fine on a Windows XP box with IE6.

As for the question on how to emerge the client-side javascript into the
DropDownList web control, we can make use of the Attributes on that web
control. For example, the following code is used to add the "onclick"
attribute to the DropDownList control:

DropDownList1.Attributes.Add("onclick", "return clickMe();")

In addition, we should render the clickMe() javascript function using the
RegisterClientScriptBlock method. For the detailed info and sample code on
this method, please check out the URLs below,

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemWebUIPageClassRegisterClientScriptBlock Topic.asp

http://msdn.microsoft.com/library/de...us/dnaspp/html
/aspnet-injectclientsidesc.asp

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #4
Thanks Jacob.
Your answer has enough information to solve this issue.
Shimon

"Jacob Yang [MSFT]" <ji***@online.microsoft.com> wrote in message
news:rY**************@cpmsftngxa06.phx.gbl...
Hi Shimon,

Have you tried the sample code in my previous reply? The sample code was
tested fine on a Windows XP box with IE6.

As for the question on how to emerge the client-side javascript into the
DropDownList web control, we can make use of the Attributes on that web
control. For example, the following code is used to add the "onclick"
attribute to the DropDownList control:

DropDownList1.Attributes.Add("onclick", "return clickMe();")

In addition, we should render the clickMe() javascript function using the
RegisterClientScriptBlock method. For the detailed info and sample code on
this method, please check out the URLs below,

http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfSystemWebUIPageClassRegisterClientScriptBlock Topic.asp

http://msdn.microsoft.com/library/de...us/dnaspp/html /aspnet-injectclientsidesc.asp

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first...
6
by: Adrienne | last post by:
http://www.intraproducts.com/beta/infinicall/index.asp has a drop down menu on Investor Relations. The markup and CSS are both valid, and most of the time, the menu drops down correctly. However,...
3
by: Matt | last post by:
I want to know if readOnly attribute doesn't work for drop down list? If I try disabled attribute, it works fine for drop down list. When I try text box, it works fine for both disabled and...
2
by: Phil Longworth | last post by:
Im very new to Access 97 and Im sure I should be able to do this but cant work out how. Im bulding a database for my stamp collection. I have two tables; one with details of all the individual...
3
by: Wayne Dyer | last post by:
I can duplicate this, so I know it's not something I'm imagining and wonder if anyone else has seen it. Take a page, put a drop down control on it, hook up the onChange event handler to go get...
4
by: rodchar | last post by:
Hey all, I was wondering againg...on my ASP.NET app I have a drop down list. I've set the control to AutoPostBack=True. When I run this app, I select something out of the drop down list and the...
17
by: Aussie Rules | last post by:
Hi, I want to have a single line combo box dropdown, but where i can selected multiple items in the drop down via a check box... I can see one in the standard tool box... is there one ? If...
7
by: hung tran | last post by:
Hi, I'd like to drop down a combobox after validating the Leave() event, how can I do that ? Thanks
2
by: Doug | last post by:
Hi, I can't figure out how to create a drop-down list box. The help file says it exists. The icon in the help file matches the combobox in the toolbox. I tried using a combox box, both with and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.