Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Javascript help!


ghost's Avatar
0 0

I need help with a script of mine that adds a onFocus and onBlur function for all inputboxes on all pages. The script will be added to a javascript file that will be loaded on all pages so to implement it on all pages isn't a problem, althou my script just won't seem to work!

Here it is:

var inputArray = document.getElementsByTagName('input');
for (i = 0; i < inputArray.length; i++){
if(inputArray[i].type == "text"){
	inputArray[i].onfocus=function(obj){ this.value="focused"; }
        inputArray[i].onblur=function(obj){ this.value="blured"; }
}
}

I debugged it as far as i can and seems to me that its the if that won't work, and yes the name IS text on inputboxes, allready checked that!

Thanx in advance.

Nevermind, fixed it now :D Updated the code for others to use.