NAME Form.Serializer - Serialize form values into various forms SYNOPSIS var serializer = new Form.Serialize("name_of_form"); // or var serializer = new Form.Serialize("id_of_form"); var qs = serializer.queryString(); var pairs = serializer.pairsArray(); for ( var i in pairs ) { document.write( pairs[i][0] + " = " + pairs[i][1] ); } var named = serializer.keyValues(); for ( var key in named ) { document.write( key + " = " ); if ( typeof named[key] == 'object' ) { document.write( named[key].join(", ") ); } else { document.write( named[key] ); } } var named = serializer.keyValues('force array for all keys'); for ( var key in named ) { document.write( key + " = " + named[key].join(", ") ); } DESCRIPTION A form serializing class that can return various serialized versions of the form. Note that when serializing a form it *does not* include the names or values of any button, submit, or image elements. METHODS * new Form.Serializer(name) * new Form.Serializer(id) * new Form.Serializer(form_element) The constructor can be given either the name or id of a form, or a form element object. It checks for an object first, then id, and finally name. If no matching form is found an exception is thrown. Returns a new object. * pairsArray() Returns an array of pairs (two-element arrays). The first element of each pair is a form element's name, and the second is the value. The same name may recur multiple times. * queryString() * queryString(separator) This method returns a properly encoded query string representing the serialized form. By default, key-value pairs are separated with a semi-colon (;). If you pass a string to this method, that string will be used as the separator. * keyValues() * keyValues(forceArray) Returns an object. The properties of the object are the form element names and the values of each property is the value(s) for that element. When the same name occurs multiple times or for multi-select elements, the value will be an array. To force *all* values to be made into array, pass a true value into this method. AUTHOR Dave Rolsky, . COPYRIGHT Copyright (c) 2005 Dave Rolsky. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as the Perl programming language (your choice of GPL or the Perl Artistic license).