// this function cannot handle the event of a single checkbox as .length becomes undefined instead of just 1 function CheckboxToString(f, fldnm, delim) { // converts a checkbox / multi-select to a string // f - form object // fldnm - name of field // delim - deliminator for returned string var str = ''; var fld = eval('f.' + fldnm); for (var m=0; m < fld.length; m++) { if (fld[m].checked) { // add to str if (str=='') { // first value to return, no comma str += fld[m].value; } else { // add to existing str values str += (delim + fld[m].value); } //alert (str); } } // done looping through values, return built str return str; } // this function handles the event of a single checkbox but has to loop through all form elements function CheckboxToString(f, fldnm, delim) { // converts a checkbox / multi-select to a string // f - form object // fldnm - name of field // delim - deliminator for returned string var str = ''; var fld; for (var m=0; m <=f.elements.length; m++) { fld = f.elements[m]; // do test of undefined workaround if (fld && typeof fld.type != 'undefined') { // since type should exist now, check for type of checkbox if (fld.type == 'checkbox') { if (fld.name == fldnm) { // have the or one of the tmpMailSvrs checkboxes if (fld.checked) { // add to str if (str=='') { // first value to return, no comma str += fld.value; } else { // add to existing str values str += (delim + fld.value); } //alert (str); } } } } } // done looping through values, return built str return str; }