...

View Full Version : how can i call an event from code?



LottaLava
10-09-2003, 04:32 PM
Hello folks, i have some text fields in some web page, and each text field has its event onBlur one method named onBlur_doSomething( ), iīd like to known how can i call those event from code? Something like:

var frm = document.forms[ 0 ];

for ( var i = 0; i < frm.elements.length; i++ )
{
if ( frm.elements[ i ].type == "text" )
frm.elements[ i ]onblur( ); // I really donīt known how:
}


Regards,
lottalava:D

Kor
10-09-2003, 05:48 PM
onBlur_doSomething( ) looks like a function, not a method, so I confess I don't understand your problem. Can u detail, please?

LottaLava
10-09-2003, 07:03 PM
onBlur_doSomething( ) is a function that i bind as onClickīs event of all textfield ( <input type="text"> ) that i have in my page, all i want is call this method from code because it starts some task for each textfield.

Regards,
Edson

Danne
10-09-2003, 07:20 PM
Try this:


frm.elements[ i ].blur( );

LottaLava
10-09-2003, 07:27 PM
That is right, but if textfield is disabled it donīt work.

Danne
10-09-2003, 07:38 PM
Then you need to check if it's disabled first:


if (!frm.elements[i].disabled) {
frm.elements[i].blur();
}

me'
10-09-2003, 08:03 PM
or...

function foo() {
//blah...
}
document.getElementById('textbox').onClick = foo; //or onBlur, etc
//when wanting to be called:
foo();



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum