for (var i=1; i<9; i++) { if (form['defect'+i].checked == 1) f.write(form['defect'+i].value + " "); }