Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: focus() not working when in a .js file


Message #1 by KATHLEEN.M.WHALEN@c... on Wed, 28 Nov 2001 12:19:44 -0500
> I have another function that I'm using to hide/display items in a form.  
I 
> like to keep all my functions in functions.js.  In addition, to 
> hide/display I am using the function to set focus on text fields within 
> the form.  When the <SCRIPT> is located in the <HEAD> section of my HTM 
> page, it works fine.  However, when I move it to the functions.js file, 
it 
> stops working.  No error - just not working.  Everything else within the 
> function works.  Any ideas why
> 
> document.frmPassword.UserName1.focus(); 
> 
> works in the <HEAD> section but not in an included JS file?
> 
> //FUNCTION USED TO MANIPULATE EDW LOGIN FORM
> function Change(){
> if (document.frmPassword.change.checked){
>         Hide1.style.display="inline";
>         document.frmPassword.UserName2.focus(); //not working
>         RegPwd.style.display="none";
> }
> else{
>         Hide1.style.display="none";
>         RegPwd.style.display="inline";
>         document.frmPassword.UserName1.focus();//not working
>         document.frmPassword.OldPwd.value="";
>         document.frmPassword.NewPwd.value="";
>         document.frmPassword.ConfirmPwd.value="";
> }
> }
> //END

It shouldn't make any difference where you put the function (according to 
the manual anyway). Can you post the rest of your example (i.e. the form 
which this script manipulates) so people can try it out? I suppose you 
could try setting the display  to "inherit" - maybe that will make a 
difference (although I doubt

  Return to Index