Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > Web

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 04-14-2003, 07:45 PM
Igor
Guest
 
Posts: n/a
Which element has focus


Hi everybody,
Is there a way to find out whitch element has focus on DHTML form with javascript?
Thanks
Igor
Reply With Quote
  #2  
Old 04-21-2003, 08:07 PM
Michael
Guest
 
Posts: n/a
Re: Which element has focus

Igor,

You can use (and modify) this JavaScript for your needs.

function testForFocus()
{
if (document.myForm.myTxtBox.gotfocus = true)
{
alert("Text box has focus!")
}
}

This script is assuming the form name is "myForm" and the text type input is
named "myTxtBox".

Michael Sanchez
Runtime Web Development


"Igor" <irodionov@hotmail.com> wrote in message
news:3e9b2be5$1@tnews.web.devx.com...
>
> Hi everybody,
> Is there a way to find out whitch element has focus on DHTML form with

javascript?
> Thanks
> Igor



Reply With Quote
  #3  
Old 10-23-2003, 03:55 PM
Tim Ellison
Guest
 
Posts: n/a
Re: Which element has focus


Here's another approach that doesn't care about the element.

function getElementWithFocus()
{
var rtnValue = null;
for(var i=0;i<document.all.length;i++)
{
try
{
if ( document.all.items[i].gotFocus )
{
// assume that element has name and/or id.
alert( document.all.item[i].name + ' has focus!');
rtnValue = document.all.items[i];
break;
}
}
catch (ex)
{
// catch exception for when the element doesn't support the gotFocus
attribute.
}
return rtnValue;
}
}

--

Regards,

Tim Ellison, MCP
Whitlock eBusiness Solutions
(w) 804-794-2871 x144
(m) 804-405-4874

"Igor" <irodionov@hotmail.com> wrote in message
news:3e9b2be5$1@tnews.web.devx.com...
>
> Hi everybody,
> Is there a way to find out whitch element has focus on DHTML form with

javascript?
> Thanks
> Igor



Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:11 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.