...

View Full Version : disable form fields function



lithos
12-09-2004, 09:53 AM
I'm a Javascript newbie.

The following function, actived by a radio button with onClick="X_disableField(this.form)", disables some input text (text1, text2) fields.

function disableField (obj)
{
obj.X_text1.disabled=true;
obj.X_text2.disabled=false;
}


Since I have to reply this N times, I would insert in place of X a parameter like:

function disableField (obj,par)
{
obj.par_text1.disabled=true;
obj.par_text2.disabled=false;
}
which is called by onClick="Y_disableField(this.form,'Y')"

but this not works at all..... thanks!

Willy Duitt
12-09-2004, 05:54 PM
Your function is named: disableField
Not: X_disableField or Y_disableField

Of course it will not work if you are calling functions that are not present...

If you need to use this multiple times pass different parameters as arguements to the function: disableField

.....Willy

A1ien51
12-09-2004, 06:01 PM
This may work:


function disableField (obj,par)
{
obj(par + "_text1").disabled=true;
obj(par + "_text2").disabled=false;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum