Iterate Checkbox values with JS?

I have some checkboxes on a form like this: -

<form id="EventForm" name="EventForm" method="post">
 <input name="EventRecur[]" type="checkbox" class="checkbox" value="EveryDay" />
 <input name="EventRecur[]" type="checkbox" class="checkbox" value="Monday" />
 <input name="EventRecur[]" type="checkbox" class="checkbox" value="Tuesday" />

Basically im trying to get the selected values with JS, but im getting the error “document.EventForm.EventRecur is undefined”

My JS looks like this: -

function previewMessage()
	function get_check_value()
		var c_value = "";
		for (var i=0; i < document.EventForm.EventRecur.length; i++)
		    if (document.EventForm.EventRecur[i].checked)
				c_value = c_value + document.EventForm.EventRecur[i].value + "\
	//Display Submit Button
	document.getElementById("submit_button").style.display = "inline";

Any ideas where im going wrong? Is it because the field input names are arrays? e.g. EventRecur?

Many thanks!

The form name is “EventRecur” so that’s what you need to use in your script.

for (var i=0; i < document.EventForm."EventRecur[]".length; i++)

It’s only with PHP that the square brackets allow the form field to be treated as if it were an array, not JavaScript.