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

Roger Ly rogerly at bareviking.com
Mon Feb 10 16:17:01 CST 2003


Hey Tom,

function enableFields(fieldNameArray)
{
	for (i = 0; i < fieldNameArray.length; i++)
	{
		field =
document.forms["myForm"].elements[fieldNameArray[i]];
		field.disabled = false;
	}
}

Depending on how you want to create an array...

function doSomething()
{
	var myArray = new Array();
	//assuming you can loop through the fields you want to set
	for (int i = 0; i < something; i++) { // this is some loop to
get your
 							//field names
		myArray[myArray.length] = "MyFieldName";
	}
	enableFields(myArray);
}

Roger




More information about the thelist mailing list