Chris Nizzardini, Salt Lake City Utah, Web Developer Specializing in LAMP+Ajax Since 2006

My Blog

Here is my awesome blog.

looping through form fields in javascript

I needed to loop through a bunch of form fields in javascript, serialize them into a string, and then pass them to a PHP script for further manipulation. Here’s an easy way to loop through form fields that I found on the google:

for(i=0; i

Here's what my code ended up looking like:

var strArr = "";
for(i=0; i(<)document.posfrm.elements.length; i++)
{
	strArr += document.posfrm.elements[i].name + '*' + document.posfrm.elements[i].value + '|';
}

Leave a Reply