[thelist] js function with variable parameters...need advice

Tom Dell'Aringa pixelmech at yahoo.com
Mon Feb 10 16:06:00 CST 2003

Hey Volters,

I have a situation where a user changes a dropdown from "no" to
"yes". When "yes" is selected a *variable* number of fields are
changed from disabled to enabled to allow them to further fill in

My simple function to handle it that does work is this:

function enableFields(fieldName)
   field = document.forms["myForm"].elements[fieldName];
   field.disabled = false;

and is called on the onChange by doing:

I have probably *twenty* of these to handle on one page. You can see
the function works fine, but how can I make it so I can pass any
number of field names (actually like 1-3 depending on)?

Can I just put say 4 variables in the paramters and test to see if
they exist? This doesn't seem very elegant.

I'm guessing some sort of an array and for loop but I can't figure it


var me = tom.pixelmech.webDeveloper();

[Making A Commercial Case for Adopting Web Standards]

Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.

More information about the thelist mailing list