Loop thru checkboxes and compile values from selected


JavaScript


function compileemail(){
	for (i=0; i<document.forms[0].elements.length; i++) { 
		el = document.forms[0].elements[i];
		if (el.type=="checkbox" && el.name.indexOf("email")!=-1){
			if (el.checked) {
				if (emaillist) {
					var emaillist = emaillist + ", " + el.value;	
				}else{
					var emaillist = el.value;
				}
			}
		} 
	}
	document.forms[0].emaillist.value = emaillist;
}

Written by Frank Joseph Brefere III

Posted by fbrefere001 on Sunday July 6, 2008