473,609 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=""java script"">
<!--
function fnTrapKD(btnID, event){
btn = findObj(btnID);
if (document.all){
if (event.keyCode == 13){
event.returnVal ue=false;
event.cancel = true;
btn.click();
}
}
else if (document.getEl ementById){
if (event.which == 13){
event.returnVal ue=false;
event.cancel = true;
btn.focus();
btn.click();
}
}
else if(document.lay ers){
if(event.which == 13){
event.returnVal ue=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.l ength) {
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.fo rms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.l ayers&&i<d.laye rs.length;i++)
x=findObj(n,d.l ayers[i].document);
if(!x && d.getElementByI d)
x=d.getElementB yId(n);
return x;
}
// -->
</SCRIPT>";

textControl.Att ributes.Add("on keydown", "fnTrapKD(' " +
defaultButton.C lientID + "',event)") ;
thisPage.Regist erStartupScript ("ForceDefaultT oScriptImage",
theImageScript) ;
Jul 23 '05 #1
4 5247
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.goo gle.com>...
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=""java script"">
<!--
function fnTrapKD(btnID, event){
btn = findObj(btnID);
if (document.all){
if (event.keyCode == 13){
event.returnVal ue=false;
event.cancel = true;
btn.click();
}
}
else if (document.getEl ementById){
if (event.which == 13){
event.returnVal ue=false;
event.cancel = true;
btn.focus();
btn.click();
}
}
else if(document.lay ers){
if(event.which == 13){
event.returnVal ue=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.l ength) {
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.fo rms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.l ayers&&i<d.laye rs.length;i++)
x=findObj(n,d.l ayers[i].document);
if(!x && d.getElementByI d)
x=d.getElementB yId(n);
return x;
}
// -->
</SCRIPT>";

textControl.Att ributes.Add("on keydown", "fnTrapKD(' " +
defaultButton.C lientID + "',event)") ;
thisPage.Regist erStartupScript ("ForceDefaultT oScriptImage",
theImageScript) ;

Jul 23 '05 #2
If you want to turn off IE's autocomplete feature, add
autocomplete="o ff" 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="o ff" on my control, but
instead detect it. Can it be done via javascript?

/bc

"c.**********@g mail.com" <c.**********@g mail.com> wrote in message news:<11******* *************** @f14g2000cwb.go oglegroups.com> ...
If you want to turn off IE's autocomplete feature, add
autocomplete="o ff" 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.getEle mentById('name_ input').autocom plete
will return "off" if the name_input element contains
autocomplete="o ff".

If autocomplete isn't disabled then
document.getEle mentById('name_ input').autocom plete just returns
undefined. Maybe you could use that as a basis of some detection code.

Note that in Firefox document.getEle mentById('name_ input').autocom plete
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
8995
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 at a page level. Any ideas/thought would be greatly appreciated. Thanks in advance, Zac
1
1756
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 groups and tried a bunch of things. Two main areas I keep seeing are, 1. Browser Settings not set correctly. 2. Ability to turn off Autocomplete for a control and a form.
0
2066
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 all over again after it finishes the autocomplete process. I have striped down the program to a smaller version than the orginal. it now works in a multiline wx.textctrl box. belive that the program only needs one or two lines to complete the...
2
4237
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 manually pick a choice but I get an error when the choice is left at the default value, which is "Male". I have the radio box tied to an event to "see" when a choice is made, but how does it work if the person just leaves the default value? ...
2
3120
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
12652
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 need to create single line combobox style control which: 1. Allows to type first characters in name 2. Auto-completes entered data by using first match 3. Allows to open picklist based by entered data and select name
8
5741
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 can do only with ajax(xml and javascript) but i want to fetch possible values from database and want to show as the user types in text box.
1
3839
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 and send the item number to the xmlHttp and works awesome. Now I need to add an apply button next to it. so they can type in the complete number then hit apply and it does the same function. I cant get it to work with the script I have. The image...
6
7315
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 use the Tab key to finish the Autocomplete it both selects that item and moves to the next Control in the Tab Order. I personally prefer to use the Enter key (to select autocomplete items) but many users are used to the Tab key.
0
8145
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
8588
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8556
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...
1
8236
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8410
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
5526
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
4037
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...
0
4103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2541
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.