Information Technology Division

Using FormMail to Administer a Survey Online

If you don't have a Form set up already, get the Comment Form code first.

Copy and paste the following JavaScript in your document. There is a line of code at the bottom of the page that must be included in the FORM tag of your Comment Form.

		<script LANGUAGE="JavaScript">
		<!--
		function create_array(name, value)
		{
		this.name = name;
		this.value = value;
		}
		checkbox_array = new Array (100);
		var checkbox_count = 0;
		
		function check_data2 (form)
		{
		var OK, j=0;
		for ( var i=0 ; i<form.elements.length ; i++ )
		{
		if (form.elements[i].type == "checkbox")
		{
		if (!form.elements[i].checked)
		{
		checkbox_array[j++] = new
		create_array(form.elements[i].name, form.elements[i].value);
		checkbox_count++;
		
		form.elements[i].value = " ";
		form.elements[i].checked = true;
		}
		}
		else if (form.elements[i].type == "radio")
		{
		radio_name = form.elements[i].name;
		if (!form.elements[i].checked)
		{
		OK = 0;
		while (form.elements[++i].name == radio_name)
		{
		if (form.elements[i].checked)
		{
		OK = 1;
		break;
		}
		radio_name = form.elements[i].name;
		}
		if (OK)
		{
		while (form.elements[++i].name == radio_name);
		}
		else
		{
		form.elements[i-1].value = " ";
		form.elements[i-1].checked = true;
		}
		}
		else
		{
		while (form.elements[++i].name == radio_name);
		}
		i--;
		}
		else if (form.elements[i].value == " ")
		{
		form.elements[i].value = " ";
		}
		}
		return true;
		}
		//-->
		</script>
		

And the following line should be included in the FORM tag:

		<form onSubmit="return check_data2(this)"
		ACTION="http://www.mtsu.edu/cgi-bin/FormMail.pl" METHOD="POST">