473,410 Members | 1,930 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,410 software developers and data experts.

IE autocomplete and default button bind

bc
Hi,
Is it possible to detect if the IE autocomplete function in a current
context such as a textbox is activated (ie. dropdown with previously
entered info is visible)?

Problem:
I use a script as a basis for binding <enter> in textbox to a button,
BUT <enter> in the dropdown autocomplete generated by IE also triggers
this event.
The script is available below (in .NET context but the idea should
shine through).

Best regards
Brian Christensen
// Sets default buttons.
// Originally created by Janus Kamp Hansen - http://www.kamp-hansen.dk
// Extended by Darrell Norton -
http://dotnetjunkies.com/weblog/darrell.norton/
// Available at http://www.gotdotnet.com/Community/W...9-276f0620589d
string theImageScript = @"
<SCRIPT language=""javascript"">
<!--
function fnTrapKD(btnID, event){
btn = findObj(btnID);
if (document.all){
if (event.keyCode == 13){
event.returnValue=false;
event.cancel = true;
btn.click();
}
}
else if (document.getElementById){
if (event.which == 13){
event.returnValue=false;
event.cancel = true;
btn.focus();
btn.click();
}
}
else if(document.layers){
if(event.which == 13){
event.returnValue=false;
event.cancel = true;
btn.focus();
btn.click();
}
}
}

function findObj(n, d) {
var p,i,x;
if(!d)
d=document;
if((p=n.indexOf(""?""))>0 && parent.frames.length) {
d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);
}
if(!(x=d[n])&&d.all)
x=d.all[n];
for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=findObj(n,d.layers[i].document);
if(!x && d.getElementById)
x=d.getElementById(n);
return x;
}
// -->
</SCRIPT>";

textControl.Attributes.Add("onkeydown", "fnTrapKD('" +
defaultButton.ClientID + "',event)");
thisPage.RegisterStartupScript("ForceDefaultToScri ptImage",
theImageScript);
Jul 23 '05 #1
4 5233
bc
Doesn't anybody have an idea on where to proceed? If there are
alternate groups that might be able to help me out I'd appreciate if
someone post them..

Thanks...

/brian

bc****@usa.net (bc) wrote in message news:<df*************************@posting.google.c om>...
Hi,
Is it possible to detect if the IE autocomplete function in a current
context such as a textbox is activated (ie. dropdown with previously
entered info is visible)?

Problem:
I use a script as a basis for binding <enter> in textbox to a button,
BUT <enter> in the dropdown autocomplete generated by IE also triggers
this event.
The script is available below (in .NET context but the idea should
shine through).

Best regards
Brian Christensen
// Sets default buttons.
// Originally created by Janus Kamp Hansen - http://www.kamp-hansen.dk
// Extended by Darrell Norton -
http://dotnetjunkies.com/weblog/darrell.norton/
// Available at http://www.gotdotnet.com/Community/W...9-276f0620589d
string theImageScript = @"
<SCRIPT language=""javascript"">
<!--
function fnTrapKD(btnID, event){
btn = findObj(btnID);
if (document.all){
if (event.keyCode == 13){
event.returnValue=false;
event.cancel = true;
btn.click();
}
}
else if (document.getElementById){
if (event.which == 13){
event.returnValue=false;
event.cancel = true;
btn.focus();
btn.click();
}
}
else if(document.layers){
if(event.which == 13){
event.returnValue=false;
event.cancel = true;
btn.focus();
btn.click();
}
}
}

function findObj(n, d) {
var p,i,x;
if(!d)
d=document;
if((p=n.indexOf(""?""))>0 && parent.frames.length) {
d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);
}
if(!(x=d[n])&&d.all)
x=d.all[n];
for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=findObj(n,d.layers[i].document);
if(!x && d.getElementById)
x=d.getElementById(n);
return x;
}
// -->
</SCRIPT>";

textControl.Attributes.Add("onkeydown", "fnTrapKD('" +
defaultButton.ClientID + "',event)");
thisPage.RegisterStartupScript("ForceDefaultToScri ptImage",
theImageScript);

Jul 23 '05 #2
If you want to turn off IE's autocomplete feature, add
autocomplete="off" attribute to the input field that you want to use.

Thanks

Anand

Jul 23 '05 #3
bc
Tnx for suggestion! But I don't want to hack the solution by disabling
functionality, e.g by putting autocomplete="off" on my control, but
instead detect it. Can it be done via javascript?

/bc

"c.**********@gmail.com" <c.**********@gmail.com> wrote in message news:<11**********************@f14g2000cwb.googleg roups.com>...
If you want to turn off IE's autocomplete feature, add
autocomplete="off" attribute to the input field that you want to use.

Thanks

Anand

Jul 23 '05 #4
The best I was able to do was detect if autocomplete was disabled.

In IE 6 at least document.getElementById('name_input').autocomplete
will return "off" if the name_input element contains
autocomplete="off".

If autocomplete isn't disabled then
document.getElementById('name_input').autocomplete just returns
undefined. Maybe you could use that as a basis of some detection code.

Note that in Firefox document.getElementById('name_input').autocomplete
always returns undefined.

Jul 23 '05 #5

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

Similar topics

2
by: scorp7355 | last post by:
I was wondering if there is some other way to turn autocomplete off besides using "autocomplete=off", using a meta tag or something similar. It would be great if there is some way to turn it off...
1
by: thubba2000 | last post by:
We have a web application developed using IBuySpy. In older versions, Autocomplete on all web forms works. In our latest version, it stopped working on all clients. I have gone through all the...
0
by: walterigo | last post by:
hello. I have been working all too hard trying to figure out how to get TextCtrlAutoComplete.py to start another word after it finishes the last word. I want it to start the autocomplete process...
2
by: crystalattice | last post by:
In my GUI app, I have a radio box allowing the user to pick his/her gender. When I click a button, I'd like the radio box to tell the program which choice is marked. I can get it to work when I...
2
by: dneupane | last post by:
Hi all How can I get combobox autocomplete working with button click event, my application cannot use keyboard, so I have soft keypad. Any help would be greatly appreciated. Regards Niju
5
by: Andrus | last post by:
I'm creating a database Winforms application using VCS Express 2005 I have some large lookup tables (may be up to 500000 records) which contains name and id and are stored in sql server. I...
8
by: nil | last post by:
Hello all, It's urgent... i want to add autocomplete textbox facility in my application like google. as you type it suggests option to the user..i want the same kind of facility...i know i...
1
by: wkerplunk | last post by:
Below is what I have build with several different languages. It works great but I need help, I am stuck. When you click on an item in the dropdown autocomplete div it does a mousedown function...
6
by: ezyeric13 | last post by:
I have a series of ComboBox's Bound to a DataGridView and I turned the AutoComplete on for them so they list all the items in a certain collumn of the DataGridView. The problem is that when you...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.