Imx Fix in my experience
« prev next »

September 4, 2003 10:39 AM

Here's a quick little JavaScript that steps thru a form and reports the value of each element within that form, whatever the length of the form might be. This is a pretty easy little script to write, but I figured that since I had the need for it, someone else might too. The script looks like this...
function reportFormElements(obj)  {

for (var i = 0; i < obj.length; i++) {

	if (obj.elements[i].type == 'checkbox') {
	else {

The basic gist is, for each actual form element in the form, look at the value of the form element and alert that value. If it's a checkbox, then investigate the 'checked' attribute.

There are several ways to do this sort of thing, and one of them reports the value of each child node in the named form, including text nodes, html nodes. We don't want that, and only want to interrogate the actual form elements. A sample form is below, go ahead and try it...