Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus work in IE but not Firefox

Status
Not open for further replies.

RPrinceton

Programmer
Joined
Jan 8, 2003
Messages
86
Location
US
Hi Everyone,
Below is a javascript code snippet I use to position the insertion pointer on a field upon detecting an entry error. It works in IE but not Firefox. What obvious thing am I missing? I have not tried it with Opera or Netscape.
Please advise. Thx in advance.
Regards,
RPrinceton

code snippet:
function pos_csr(tabFld)
{
if (!tabFld)
{
}
else
{
document.getElementById(tabFld).focus();
}
}
 
where do you want to position it?

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
beware of active imagination: [URL unfurl="true"]http://www.coryarthus.com/[/url]

BillyRayPreachersSonIsTheLeetestHax0rDude
[banghead]
 
Hi cLFlaVa,
I would be positioning at whatever form field is contained
in the variable named tabFld on an onLoad event.
Regards,
RPrinceton
 
Hi Everyone,
I have figured this one out. It appears that Firefox keys off of the id attribute for cursor positioning when using getElementById whereas IE only requires the name attribute. I simply added the id attribute to the HTML and it now works. See below.
<input type="text" id="somefld" name="somefld">
Regards,
RPrinceton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top