PDA

View Full Version : Calling two functions on one event handler



MaTaX
05-11-2009, 04:01 PM
Ok I have this event on a text box that clears the text inside when focused on, but I also want it to change to light blue like the other text boxes I have when clicked on.

The other boxes use onFocus events, and I'm having trouble figuring out how to call both functions with the one event handler, I would like to not have to add the light blue background as a function to my clearing effect, but if it must be done thats ok.

Heres my code...

This is to clear the text box...


function checkclear(what){
if(!what._haschanged){
what.value=''
};
what._haschanged=true;
}


And this is what makes the BG's light blue when focused on...


onfocus="this.className='focus'" onblur="this.className='normal'"


Which calls this Internal CSS...


.normal
{
background-color:white;
}

.focus
{
background-color:lightblue;
}


If I'm not clear ask any questions that you like.

forum_amnesiac
05-12-2009, 06:46 AM
It is possible to attach more than 1 function to an event

If you had a function called test1() and another called test2() here is how you would call them both for onfocus.

onFocus="test1();test2()"

MaTaX
05-15-2009, 01:10 PM
well I thought I tried that, but I'll try it again

Nile
05-15-2009, 01:24 PM
Here, do this:


onfocus="checkclear();this.className='focus';" onblur="this.className='normal';"