<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>D-talk - Javascript</title>
    <link>http://blog.dynom.nl/</link>
    <description>The little things that pop into mind</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.2-beta4 - http://www.s9y.org/</generator>
    
    

<item>
    <title>Forms, buttons and prototypeJS's getInputs()</title>
    <link>http://blog.dynom.nl/archives/Forms,-buttons-and-prototypeJSs-getInputs_20101019_60.html</link>
            <category>Javascript</category>
    
    <comments>http://blog.dynom.nl/archives/Forms,-buttons-and-prototypeJSs-getInputs_20101019_60.html#comments</comments>
    <wfw:comment>http://blog.dynom.nl/wfwcomment.php?cid=60</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.dynom.nl/rss.php?version=2.0&amp;type=comments&amp;cid=60</wfw:commentRss>
    

    <author>nospam@example.com (Mark van der Velden)</author>
    <content:encoded>
    &lt;p&gt;In forms you use input elements to send your form. But you can also use &quot;button&quot; elements to achieve the same goal. Quite recently someone committed changes into a framework I use often and changed the &quot;input&quot; elements to &quot;button&quot; elements. Normally this is no problem, but in this case it broke some Javascript I had going on. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;I used to use the following:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;javascript&quot; style=&quot;text-align: left&quot;&gt;$&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;myForm&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getInputs&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;submit&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;button&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// .. &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;But with this function you don&#039;t get any &quot;button&quot; elements, to solve this situation I changed it to:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;javascript&quot; style=&quot;text-align: left&quot;&gt;$&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;myForm&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;select&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;button&#039;&lt;/span&gt;, &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;input[type=submit]&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;button&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// .. &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;It works fine however simply filtering on &#039;button&#039; might be too greedy and some tweaking might be required. I use this to to track down which button was pressed by the user and act accordingly (e.g. &quot;Save and close&quot; versus &quot;save&quot;). &lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 19 Oct 2010 12:36:00 +0200</pubDate>
    <guid isPermaLink="false">http://blog.dynom.nl/archives/guid_20101019_60.html</guid>
    <category>buttons</category>
<category>form</category>
<category>javascript</category>
<category>prototypejs</category>

</item>

</channel>
</rss>
