User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 430,100 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,183 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1629 | Replies: 1
Reply
Join Date: Feb 2008
Posts: 1
Reputation: orico is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
orico orico is offline Offline
Newbie Poster

Troubleshooting Control refuses to get focus

  #1  
Feb 4th, 2008
Hello all,
I have a few '<input type="text" />' controls on my ASP.NET 2.0 generated page.
Every text-box control has it's specific tab-index.
When I try to move focus to this specific text-box control on this page the focus is shifted to the window element instead of the control itself.
On every other text-box control on the page the focus is received fine.
To apply focus to this element I use the code:
document.all.elemName.focus();

This is the control itself:
    <input name       = "ctl00$EditMasterContent$c_carats"
           type       = "text"
           maxlength  = "10"
           id         = "ctl00_EditMasterContent_c_carats"
           tabindex   = "6"
           class      = "textbox1"
           onchange   = "registerOnChangeAction(&quot;caratsChanged&quot;);"
           onkeypress = "javascript:ChkNumberKeyPress(false);"
           onfocus    = "initFocusedElementsVar(this.id);"
           style      = "width: 100px;" />

Some other text-box control on the page:
    <input name       = "ctl00$EditMasterContent$c_stones"
           type       = "text"
           maxlength  = "5"
           id         = "ctl00_EditMasterContent_c_stones"
           tabindex   = "5"
           class      = "textbox1"
           onchange   = "registerOnChangeAction(&quot;stonesChanged&quot;);"
           onkeypress = "javascript:ChkNumberKeyPress(false);"
           onfocus    = "initFocusedElementsVar(this.id);"
           style      = "width: 100px;" />
Last edited by orico : Feb 4th, 2008 at 1:14 am. Reason: typing mistake
Attached Files
File Type: txt view-source.txt (110.8 KB, 3 views)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,871
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 345
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Control refuses to get focus

  #2  
Feb 4th, 2008
Try document.forms[0].elements['yourElementName'].focus(). Don't use document.all. It's not a standard property of the document object. And having a 1.8K line source file is bad in itself IMO.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 2:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC