<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Garrick Cheung &#187; form</title>
	<atom:link href="http://www.garrickcheung.com/tag/form/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.garrickcheung.com</link>
	<description>Sharing what I know and learn about CSS, MooTools, Javascript, PHP and etc.</description>
	<lastBuildDate>Fri, 30 Sep 2011 05:16:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Get Around Form submit() Mapping</title>
		<link>http://www.garrickcheung.com/javascript/get-around-form-submit-mapping/</link>
		<comments>http://www.garrickcheung.com/javascript/get-around-form-submit-mapping/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 06:32:27 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[HTML / XHTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[submit()]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=131</guid>
		<description><![CDATA[If you&#8217;ve had to use javascript to submit a form, you may have used the forms submit() method. You may also experienced difficulty, such as a &#8220;submit is not a function&#8221; error. It has to deal with mapping and I&#8217;ve got a very simple solution. The Setup: Just so you know, this is done with [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve had to use javascript to submit a form, you may have used the forms submit() method. You may also experienced difficulty, such as a &#8220;submit is not a function&#8221; error. It has to deal with mapping and I&#8217;ve got a very simple solution.<span id="more-131"></span></p>
<h3>The Setup:</h3>
<p>Just so you know, this is done with MooTools 1.2, but if you know javascript, you can build it from scratch.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;form id=&quot;response_form&quot; action=&quot;response.html&quot; method=&quot;get&quot;&gt;
    &lt;fieldset&gt;
        &lt;legend&gt;Test&lt;/legend&gt;
        Grab the response.
        &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot; /&gt;
    &lt;/fieldset&gt;
&lt;/form&gt;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> form <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'response_form'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
form.<span style="color: #660066;">getElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[type=submit]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    e.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    form.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<h3>The Test:</h3>
<p>Copy the code into a test html file. Open Firebug (you DO have Firebug and FireFox, don&#8217;t you?) and display the console. Click on the submit button and there should be an error.</p>
<h3>The Solution:</h3>
<p>Very simple now. Change the name to anything besides submit and you&#8217;ve fixed the mapping issue.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;submit&quot; name=&quot;submit_btn&quot; value=&quot;submit&quot; /&gt;</pre></td></tr></table></div>

<p>This one took me a while to find, but I was glad when I did. I hope this is helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/get-around-form-submit-mapping/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

