<?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>36Flavours.com &#187; form</title>
	<atom:link href="http://36flavours.com/tag/form/feed/" rel="self" type="application/rss+xml" />
	<link>http://36flavours.com</link>
	<description>A taste of something different...</description>
	<lastBuildDate>Mon, 19 Apr 2010 20:01:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>JS submit is not a function</title>
		<link>http://36flavours.com/2008/03/js-submit-is-not-a-function/</link>
		<comments>http://36flavours.com/2008/03/js-submit-is-not-a-function/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 21:45:02 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[submit]]></category>

		<guid isPermaLink="false">http://sha.re.it/2008/03/25/js-submit-is-not-a-function/</guid>
		<description><![CDATA[Today I was asked by a colleague to aid them with adding functionality to a form that would allow it to be submitted by pressing &#8216;ctr + s&#8217; keys. As a group of web developers this key combination is something that comes almost naturally to us when editing and constantly saving code, so should prove [...]]]></description>
			<content:encoded><![CDATA[<p class="first">Today I was asked by a colleague to aid them with adding functionality to a form that would allow it to be submitted by pressing &#8216;ctr + s&#8217; keys.</p>
<p>As a group of web developers this key combination is something that comes almost naturally to us when editing and constantly saving code, so should prove a useful addition to the form that is not too difficult to implement.</p>
<p>I began by setting up the event observers to watch for the two required keys to be pressed.</p>
<p>Once the required key codes ( 17 and 83 ) were captured it should have been a case of simply referencing the form and applying the submit method.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'form_id'</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To see if what was written so far would actually perform the desired action we tested the page using our default browser <a href="http://www.mozilla.com/firefox/" title="Mozilla Firefox" target="_blank">Firefox</a>, only to discover we were receiving the following error:</p>
<blockquote><p>document.forms.form_id.submit is not a function</p></blockquote>
<p>This was all very puzzling but eventually resorting to a search on <a href="http://www.google.co.uk/search?q=submit+is+not+a+function" title="Google Search Results" target="_blank">Google</a> provided a number of answers.</p>
<p>It turns out that all our problems came back to the fact that the submit button on the form had been given the name of &#8216;submit&#8217; &#8211; which is a JavaScript reserved word &#8211; resulting in ambiguity in the browser and therefore no longer referencing the method.</p>
<p>The solution to this is a very simple one &#8211; renaming the submit button to anything other than &#8216;submit&#8217; or any of the <a href="http://www.javascriptkit.com/jsref/reserved.shtml" title="List of reserved words in JavaScript" target="_blank">reserved words</a> in JavaScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2008/03/js-submit-is-not-a-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
