Drop down behavior

  • Thread starter Thread starter shimonsim
  • Start date Start date
S

shimonsim

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.
 
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.
 
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.
 
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/default.asp?url=/library/en-us/cpref/html/
frlrfSystemWebUIPageClassRegisterClientScriptBlockTopic.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-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.
 
Back
Top