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;" />

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.