If you look at the function colour_background() - I'm trying to send the current name to be able to referr to the element from my function.
(which looks like this)
//forms script
function colour_background(object, formNumber) {
var active;
if (active)
{
document.forms[0].object.style.backgroundColor = "#FFF7DF";
active = true;
}
else
{
document.forms[0].object.style.backgroundColor = "#fff";
active = false;
}
}
it would be nice to be able to loop through all the input elements on the page and place a call for this function in all "onfocus" and "onblur" attributes. Does anyone know how to accomplish this?
Du behöver inte använda this.name för att referera till objektet eftersom "this" är en direkt referens.
"active" variabeln är lokal så du kommer alltid hamna i else-satsen.