Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through checkboxes

Status
Not open for further replies.

smellykat

Programmer
Mar 4, 2002
33
US
I need a function that will loop through the checkboxes I have on my form - all with the same name - and check that at least one box is checked. If not, alert them that it is required.
Any ideas?
 
try
Code:
function NoneSelected(objCheckbox)
{
	var Result = true;
	for(var i=0;i<objCheckbox.length;i++)
	{
		if (objCheckbox[i].checked)
		{
			Result = false;
			break;
		}
	}
	return Result;
} //NoneSelected
call it like NoneSelected(document.formName.checkboxName)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top