<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Prototype JavaScript framework - Form</title>
  <id>tag:www.prototypejs.org,2009:mephisto/api/form</id>
  <generator uri="http://mephistoblog.com" version="0.7.3">Mephisto Noh-Varr</generator>
  <link href="http://www.prototypejs.org:80/feed/api/form/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.prototypejs.org:80/api/form" rel="alternate" type="text/html"/>
  <updated>2007-03-09T20:02:49Z</updated>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Mislav</name>
    </author>
    <id>tag:www.prototypejs.org:80,2007-03-09:14756</id>
    <published>2007-03-09T18:38:00Z</published>
    <updated>2007-03-09T20:02:49Z</updated>
    <category term="Form"/>
    <category term="1.5.1"/>
    <link href="http://www.prototypejs.org:80/api/form/request" rel="alternate" type="text/html"/>
    <title>request</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;request([options]) -&gt; new Ajax.Request&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A convenience method for serializing and submitting the form via an Ajax.Request to the URL of the form&#8217;s &lt;code&gt;action&lt;/code&gt; attribute. The &lt;code&gt;options&lt;/code&gt; parameter is passed to the Ajax.Request instance, allowing to override the HTTP method and to specify additional parameters.&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;request([options]) -&gt; new Ajax.Request&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A convenience method for serializing and submitting the form via an Ajax.Request to the URL of the form&#8217;s &lt;code&gt;action&lt;/code&gt; attribute. The &lt;code&gt;options&lt;/code&gt; parameter is passed to the Ajax.Request instance, allowing to override the HTTP method and to specify additional parameters.&lt;/p&gt;
&lt;p&gt;Options passed to &lt;code&gt;request()&lt;/code&gt; are intelligently merged with the underlying &lt;a href=&quot;/api/ajax/options&quot;&gt;&lt;code&gt;Ajax.Request&lt;/code&gt; options&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the form has a method attribute, its value is used for the &lt;code&gt;Ajax.Request&lt;/code&gt; &lt;code&gt;method&lt;/code&gt; option.  If a method option is passed to &lt;code&gt;request()&lt;/code&gt;, it takes precedence over the form&#8217;s method attribute. If neither is specified, method defaults to &#8220;POST&#8221;. &lt;/li&gt;
&lt;li&gt;Key-value pairs specified in the &lt;code&gt;parameters&lt;/code&gt; option (either as a hash or a query string) will be merged with (and &lt;em&gt;take precedence&lt;/em&gt; over) the serialized form parameters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Example&lt;/h3&gt;

&lt;p&gt;Suppose you have this HTML form:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;html&quot;&gt;&amp;lt;form id=&amp;quot;person-example&amp;quot; method=&amp;quot;POST&amp;quot; action=&amp;quot;/user/info&amp;quot;&amp;gt;
  &amp;lt;fieldset&amp;gt;&amp;lt;legend&amp;gt;User info&amp;lt;/legend&amp;gt;
  &amp;lt;div&amp;gt;&amp;lt;label for=&amp;quot;username&amp;quot;&amp;gt;Username:&amp;lt;/label&amp;gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;username&amp;quot; id=&amp;quot;username&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;&amp;lt;label for=&amp;quot;age&amp;quot;&amp;gt;Age:&amp;lt;/label&amp;gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;age&amp;quot; id=&amp;quot;age&amp;quot; value=&amp;quot;&amp;quot; size=&amp;quot;3&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;

  &amp;lt;div&amp;gt;&amp;lt;label for=&amp;quot;hobbies&amp;quot;&amp;gt;Your hobbies are:&amp;lt;/label&amp;gt;
  &amp;lt;select name=&amp;quot;hobbies[]&amp;quot; id=&amp;quot;hobbies&amp;quot; multiple=&amp;quot;multiple&amp;quot;&amp;gt;
    &amp;lt;option&amp;gt;coding&amp;lt;/option&amp;gt;
    &amp;lt;option&amp;gt;swimming&amp;lt;/option&amp;gt;
    &amp;lt;option&amp;gt;hiking&amp;lt;/option&amp;gt;
    &amp;lt;option&amp;gt;drawing&amp;lt;/option&amp;gt;
  &amp;lt;/select&amp;gt;
 &amp;lt;/div&amp;gt;
  &amp;lt;div class=&amp;quot;buttonrow&amp;quot;&amp;gt;&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;serialize!&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can easily post it with Ajax like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;
$('person-example').request(); //done - it's posted

// do the same with a callback:
$('person-example').request({
  onComplete: function(){ alert('Form data saved!') }
})&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To override the HTTP method and add some parameters, simply use &lt;code&gt;method&lt;/code&gt; and &lt;code&gt;parameters&lt;/code&gt; in the options. In this example we set the method to GET and set two fixed parameters: &lt;code&gt;interests&lt;/code&gt; and &lt;code&gt;hobbies&lt;/code&gt;. The latter already exists in the form but this value will take precedence.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;$('person-example').request({
  method: 'get',
  parameters: { interests:'JavaScript', 'hobbies[]':['programming', 'music'] },
  onComplete: function(){ alert('Form data saved!') }
})&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-12-05:12746</id>
    <published>2006-12-05T21:44:00Z</published>
    <updated>2007-01-16T16:53:13Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form" rel="alternate" type="text/html"/>
    <title>Form</title>
<content type="html">
            &lt;p&gt;Form is a namespace and a module for all things form-related, packed with form manipulation and serialization goodness. While it holds methods dealing with forms as whole, its submodule &lt;a href=&quot;form/element&quot;&gt;&lt;code&gt;Form.Element&lt;/code&gt;&lt;/a&gt; deals with specific form controls.&lt;/p&gt;

&lt;p&gt;Most of these methods are also available directly on FORM elements that have been extended (see &lt;a href=&quot;/learn/extensions&quot;&gt;&#8220;How Prototype extends the DOM&#8221;&lt;/a&gt;).&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-11-02:12420</id>
    <published>2006-11-02T23:21:00Z</published>
    <updated>2006-12-08T15:28:52Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form/findFirstElement" rel="alternate" type="text/html"/>
    <title>findFirstElement</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;findFirstElement(formElement) -&gt; HTMLElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finds first non-hidden, non-disabled form control.&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;findFirstElement(formElement) -&gt; HTMLElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finds first non-hidden, non-disabled form control.&lt;/p&gt;
&lt;p&gt;The returned object is either an INPUT, SELECT or TEXTAREA element. This method is used by the &lt;a href=&quot;focusFirstElement&quot;&gt;&lt;code&gt;focusFirstElement()&lt;/code&gt;&lt;/a&gt; method.&lt;/p&gt;

&lt;h3&gt;Note&lt;/h3&gt;

&lt;p&gt;The result of this method is the element that comes first in the &lt;em&gt;document&lt;/em&gt; order, not the &lt;a href=&quot;http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1&quot;&gt;tabindex order&lt;/a&gt;.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-11-02:12421</id>
    <published>2006-11-02T23:21:00Z</published>
    <updated>2007-07-03T12:32:04Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form/focusFirstElement" rel="alternate" type="text/html"/>
    <title>focusFirstElement</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;focusFirstElement(formElement) -&gt; HTMLFormElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Gives keyboard focus to the first element of the form.&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;focusFirstElement(formElement) -&gt; HTMLFormElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Gives keyboard focus to the first element of the form.&lt;/p&gt;
&lt;p&gt;Uses &lt;a href=&quot;findFirstElement&quot;&gt;&lt;code&gt;Form.findFirstElement()&lt;/code&gt;&lt;/a&gt; to get the first element and calls &lt;a href=&quot;element/activate&quot;&gt;&lt;code&gt;activate()&lt;/code&gt;&lt;/a&gt; on it. This is useful for enhancing usability on your site by bringing focus on page load to forms such as search forms or contact forms where a user is ready to start typing right away.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-11-02:12419</id>
    <published>2006-11-02T23:20:00Z</published>
    <updated>2007-01-15T20:19:50Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form/enable" rel="alternate" type="text/html"/>
    <title>enable</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;enable(formElement) -&gt; HTMLFormElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enables a fully or partially disabled form.&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;enable(formElement) -&gt; HTMLFormElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enables a fully or partially disabled form.&lt;/p&gt;
&lt;p&gt;Enabling the form is done by iterating over form elements and enabling them.&lt;/p&gt;

&lt;h3&gt;Example&lt;/h3&gt;

&lt;p&gt;See the interactive example in the &lt;a href=&quot;./disable&quot;&gt;disable()&lt;/a&gt; method, which is basically it.&lt;/p&gt;

&lt;h3&gt;Note&lt;/h3&gt;

&lt;p&gt;This will enable all form controls regardless of how they were disabled (by scripting or by HTML attributes).&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-11-02:12417</id>
    <published>2006-11-02T23:19:00Z</published>
    <updated>2006-12-08T15:36:37Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form/getInputs" rel="alternate" type="text/html"/>
    <title>getInputs</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;getInputs(formElement [, type [, name]]) -&gt; array&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Returns a collection of all INPUT elements in a form. Use optional &lt;code&gt;type&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt; arguments to restrict the search on these attributes.&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;getInputs(formElement [, type [, name]]) -&gt; array&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Returns a collection of all INPUT elements in a form. Use optional &lt;code&gt;type&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt; arguments to restrict the search on these attributes.&lt;/p&gt;
&lt;h3&gt;Example&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;var form = $('myform')

form.getInputs()       // -&gt; all INPUT elements
form.getInputs('text') // -&gt; only text inputs

var buttons = form.getInputs('radio', 'education')
// -&gt; only radio buttons of name &quot;education&quot;

// now disable these radio buttons:
buttons.invoke('disable')&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Note&lt;/h3&gt;

&lt;p&gt;Input elements are returned in the &lt;em&gt;document&lt;/em&gt; order, not the &lt;a href=&quot;http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1&quot;&gt;tabindex order&lt;/a&gt;.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-11-02:12418</id>
    <published>2006-11-02T23:19:00Z</published>
    <updated>2007-03-11T14:00:25Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form/disable" rel="alternate" type="text/html"/>
    <title>disable</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;disable(formElement) -&gt; HTMLFormElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Disables the form as whole. Form controls will be visible but uneditable.&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;disable(formElement) -&gt; HTMLFormElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Disables the form as whole. Form controls will be visible but uneditable.&lt;/p&gt;
&lt;p&gt;Disabling the form is done by iterating over form elements and disabling them.&lt;/p&gt;

&lt;h3&gt;Can I try it?&lt;/h3&gt;

&lt;p&gt;Sure, here's an example:&lt;/p&gt;

&amp;lt;form class=&quot;example&quot; action=&quot;#&quot; onsubmit=&quot;return false&quot; id=&quot;disable-example&quot;&gt;
  &lt;fieldset&gt;&lt;legend&gt;User info&lt;/legend&gt;
  &lt;div&gt;&amp;lt;label for=&quot;username&quot;&gt;Username:&amp;lt;/label&gt; &amp;lt;input name=&quot;username&quot; type=&quot;text&quot; id=&quot;username&quot; value=&quot;Sulien&quot; /&gt;&lt;/div&gt;
  &lt;div&gt;&amp;lt;label for=&quot;age&quot;&gt;Age:&amp;lt;/label&gt; &amp;lt;input name=&quot;age&quot; size=&quot;3&quot; type=&quot;text&quot; id=&quot;age&quot; value=&quot;23&quot; /&gt;&lt;/div&gt;

  &lt;div&gt;&amp;lt;label for=&quot;hobbies&quot;&gt;Your hobbies are:&amp;lt;/label&gt;
  &amp;lt;select name=&quot;hobbies&quot; id=&quot;hobbies&quot; multiple=&quot;multiple&quot;&gt;
    &amp;lt;option&gt;coding&amp;lt;/option&gt;
    &amp;lt;option&gt;swimming&amp;lt;/option&gt;
    &amp;lt;option&gt;hiking&amp;lt;/option&gt;
    &amp;lt;option&gt;drawing&amp;lt;/option&gt;
  &amp;lt;/select&gt;&lt;/div&gt;

  &lt;div class=&quot;buttonrow&quot;&gt;&amp;lt;button onclick=&quot;var form = $('disable-example'); form[form.disabled ? 'enable' : 'disable'](); form.disabled = !form.disabled;&quot;&gt;Toggle disabled!&amp;lt;/button&gt;&lt;/div&gt;
  &lt;/fieldset&gt;
&amp;lt;/form&gt;

&lt;p&gt;Code attached to the onclick handler for the button is:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;var form = $('disable-example');
// cycle between calling form.disable() and form.enable()
form[form.disabled ? 'enable' : 'disable']();
form.disabled = !form.disabled;&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Note&lt;/h3&gt;

&lt;p&gt;Keep in mind that &lt;em&gt;disabled elements are skipped&lt;/em&gt; by serialize methods! You cannot serialize a disabled form.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-11-02:12415</id>
    <published>2006-11-02T23:18:00Z</published>
    <updated>2007-05-14T06:28:23Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form/serializeElements" rel="alternate" type="text/html"/>
    <title>serializeElements</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;serializeElements(elements[, getHash = false]) -&gt; string&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Serialize an array of form elements to a string suitable for Ajax requests (default behavior) or, if optional &lt;code&gt;getHash&lt;/code&gt; evaluates to &lt;code&gt;true&lt;/code&gt;, an object hash where keys are form control names and values are data..&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;serializeElements(elements[, getHash = false]) -&gt; string&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Serialize an array of form elements to a string suitable for Ajax requests (default behavior) or, if optional &lt;code&gt;getHash&lt;/code&gt; evaluates to &lt;code&gt;true&lt;/code&gt;, an object hash where keys are form control names and values are data..&lt;/p&gt;
&lt;p&gt;The preferred method to serialize a form is &lt;a href=&quot;serialize&quot;&gt;&lt;code&gt;Form.serialize&lt;/code&gt;&lt;/a&gt;. Refer to it for further information and examples on the &lt;code&gt;getHash&lt;/code&gt; parameter. However, with &lt;code&gt;serializeElements&lt;/code&gt; you can serialize &lt;em&gt;specific&lt;/em&gt; input elements of your choice, allowing you to specify a subset of form elements that you want to serialize data from.&lt;/p&gt;

&lt;h3&gt;Example&lt;/h3&gt;

&lt;p&gt;To serialize all input elements of type &quot;text&quot;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;
Form.serializeElements( $('myform').getInputs('text') )
// -&gt; serialized data
&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-11-02:12416</id>
    <published>2006-11-02T23:18:00Z</published>
    <updated>2006-12-08T15:10:53Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form/getElements" rel="alternate" type="text/html"/>
    <title>getElements</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;getElements(formElement) -&gt; array&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Returns a collection of all form controls within a form.&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;getElements(formElement) -&gt; array&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Returns a collection of all form controls within a form.&lt;/p&gt;
&lt;h3&gt;Note&lt;/h3&gt;

&lt;p&gt;OPTION elements are not included in the result; only their parent SELECT control is.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-11-02:12414</id>
    <published>2006-11-02T23:15:00Z</published>
    <updated>2007-05-14T06:27:46Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form/serialize" rel="alternate" type="text/html"/>
    <title>serialize</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;serialize(formElement[, getHash = false]) -&gt; String | object&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Serialize form data to a string suitable for Ajax requests (default behavior) or, if optional &lt;code&gt;getHash&lt;/code&gt; evaluates to &lt;code&gt;true&lt;/code&gt;, an object hash where keys are form control names and values are data.&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;serialize(formElement[, getHash = false]) -&gt; String | object&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Serialize form data to a string suitable for Ajax requests (default behavior) or, if optional &lt;code&gt;getHash&lt;/code&gt; evaluates to &lt;code&gt;true&lt;/code&gt;, an object hash where keys are form control names and values are data.&lt;/p&gt;
&lt;p&gt;Depending of whether or not the optional parameter &lt;code&gt;getHash&lt;/code&gt; evaluates to &lt;code&gt;true&lt;/code&gt;, the result is either an object of the form &lt;code&gt;{name: &quot;johnny&quot;, color: &quot;blue&quot;}&lt;/code&gt; or a string of the form &lt;code&gt;&quot;name=johnny&amp;amp;color=blue&quot;&lt;/code&gt;, suitable for parameters in an Ajax request. This method mimics the way browsers serialize forms natively so that form data can be sent without refreshing the page.&lt;/p&gt;

&lt;p class=&quot;deprecated&quot;&gt;As of Prototype 1.5 the &lt;em&gt;preferred&lt;/em&gt; form of passing parameters to an Ajax request is with an &lt;em&gt;object hash&lt;/em&gt;. This means you should pass &lt;code&gt;true&lt;/code&gt; for the optional argument. The old behavior (serializing to string) is kept for backwards-compatibility.&lt;/p&gt;

&lt;h3&gt;Interactive example&lt;/h3&gt;

&lt;p&gt;The following code is all there is to it:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;
$('person-example').serialize()
// -&gt; 'username=sulien&amp;age=22&amp;hobbies=coding&amp;hobbies=hiking'

$('person-example').serialize(true)
// -&gt; {username: 'sulien', age: '22', hobbies: ['coding', 'hiking']}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Try it for yourself!&lt;/p&gt;

&amp;lt;form class=&quot;example&quot; action=&quot;#&quot; onsubmit=&quot;alert($(this).serialize()); return false&quot; id=&quot;person-example&quot;&gt;
  &lt;fieldset&gt;&lt;legend&gt;User info&lt;/legend&gt;
  &lt;div&gt;&amp;lt;label for=&quot;username&quot;&gt;Username:&amp;lt;/label&gt; &amp;lt;input name=&quot;username&quot; type=&quot;text&quot; id=&quot;username&quot; value=&quot;&quot; /&gt;&lt;/div&gt;
  &lt;div&gt;&amp;lt;label for=&quot;age&quot;&gt;Age:&amp;lt;/label&gt; &amp;lt;input name=&quot;age&quot; size=&quot;3&quot; type=&quot;text&quot; id=&quot;age&quot; value=&quot;&quot; /&gt;&lt;/div&gt;

  &lt;div&gt;&amp;lt;label for=&quot;hobbies&quot;&gt;Your hobbies are:&amp;lt;/label&gt;
  &amp;lt;select name=&quot;hobbies&quot; id=&quot;hobbies&quot; multiple=&quot;multiple&quot;&gt;
    &amp;lt;option&gt;coding&amp;lt;/option&gt;
    &amp;lt;option&gt;swimming&amp;lt;/option&gt;
    &amp;lt;option&gt;hiking&amp;lt;/option&gt;
    &amp;lt;option&gt;drawing&amp;lt;/option&gt;
  &amp;lt;/select&gt;
 &lt;/div&gt;
  &lt;div class=&quot;buttonrow&quot;&gt;&amp;lt;input type=&quot;submit&quot; value=&quot;serialize!&quot; /&gt;&lt;/div&gt;
  &lt;/fieldset&gt;
&amp;lt;/form&gt;

&lt;h3&gt;Notes&lt;/h3&gt;

&lt;p class=&quot;notice&quot;&gt;Disabled form elements are not serialized (as per W3C HTML recommendation). Also, file inputs are skipped as they cannot be serialized and sent using only JavaScript.&lt;/p&gt;

&lt;p&gt;Keep in mind that &quot;hobbies&quot; multiple select should really be named &quot;hobbies[]&quot; if we're posting to a PHP or Ruby on Rails backend because we want to send an &lt;em&gt;array&lt;/em&gt; of values instead of a single one. This has nothing to do with JavaScript - Prototype doesn't do any magic with the names of your controls, leaving these decisions entirely up to you.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.prototypejs.org:80/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:www.prototypejs.org:80,2006-11-02:12413</id>
    <published>2006-11-02T23:12:00Z</published>
    <updated>2006-12-08T15:12:20Z</updated>
    <category term="Form"/>
    <link href="http://www.prototypejs.org:80/api/form/reset" rel="alternate" type="text/html"/>
    <title>reset</title>
<summary type="html">&lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;reset(formElement) -&gt; HTMLFormElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Resets a form to its default values.&lt;/p&gt;</summary><content type="html">
            &lt;pre&gt;&lt;code class=&quot;ebnf&quot;&gt;reset(formElement) -&gt; HTMLFormElement&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Resets a form to its default values.&lt;/p&gt;
&lt;p&gt;Example usage:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;Form.reset('contact')

// equivalent:
$('contact').reset()

// both have the same effect as pressing the reset button&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This method allows you to programatically reset a form. It is a wrapper for the &lt;code&gt;reset()&lt;/code&gt; method native to &lt;code&gt;HTMLFormElement&lt;/code&gt;.&lt;/p&gt;
          </content>  </entry>
</feed>
