var JSUtil = { parseFormElement : function(form){ var items = []; for(var i = 0; i < form.elements.length; i++){ var element = form.elements[i]; switch(element.tagName){ case "INPUT": switch(element.type){ case "text": case "hidden": case "password": case "submit": case "radio": items.push(this.createHiddenInput(element.name, element.value)); break; case "checkbox": if(element.checked) items.push(this.createHiddenInput(element.name, element.value)); break; case "reset": break; case "image": break; case "file": break; case "button": break; } break; case "SELECT": if(element.multiple){ for(var j = 0; j < element.options.length; j++){ var option = element.options[j]; if(option.selected) items.push(this.createHiddenInput(element.name, option.value)); } }else{ items.push(this.createHiddenInput(element.name, element.value)); } break; case "TEXTAREA": items.push(this.createHiddenInput(element.name, element.value)); break; } } return items; }, createForm : function(elements){ var f = document.createElement("form"); this.setFormElement(f, elements); return f; }, setFormElement : function(form, elements){ var items = elements || []; for(var i in items){ form.appendChild(this.createHiddenInput(items[i].name, items[i].value)); } }, createHiddenInput : function(name, value){ var e = document.createElement("input"); e.type = "hidden"; e.name = name; e.value = value || ""; return e; } }