Page is a not externally linkable
le_gber - 3:11 pm on May 8, 2009 (gmt 0)
The goal: I have a form with different default fields values (name, surname, email). I want to empty the field onfocus and put the default value back onblur if the field is empty. I am trying to be clever and do the whole form in one js function (I know how to do it if I create a function for each individual field). I've got an issue on the following: at the moment I get 'namedItem' in my alert box. I tried but that doesn't work either it alerts '[object MouseEvent]' Basically I need somebody to tell me how to pass 'i' inside the function, and I'd be forever grateful to them - I've been trying to do this for the entire afternoon :( I promise to share the finished file :)
Hi all, window.onload = function(){
if(document.getElementById('myform')){
ffields = document.getElementById('myform').getElementsByTagName('input');
for(f in ffields){
ffields[i].onclick = function(){ alert(i); }
}
}
} ffields[i].onclick = function(){ alert(i); }