<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: How to dynamically add form elements via JavaScript</title>
	<atom:link href="http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/</link>
	<description>Random Snippets of Code for Web Developers</description>
	<lastBuildDate>Thu, 19 Jan 2012 11:30:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Allen Liu</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-65254</link>
		<dc:creator>Allen Liu</dc:creator>
		<pubDate>Sat, 17 Dec 2011 21:18:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-65254</guid>
		<description>You&#039;re welcome =)  I&#039;m glad it helped out.

Allen</description>
		<content:encoded><![CDATA[<p>You&#8217;re welcome =)  I&#8217;m glad it helped out.</p>
<p>Allen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lokki</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-65248</link>
		<dc:creator>Lokki</dc:creator>
		<pubDate>Sat, 17 Dec 2011 21:11:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-65248</guid>
		<description>Thank you Allen for this perfect tutorial.</description>
		<content:encoded><![CDATA[<p>Thank you Allen for this perfect tutorial.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Liu</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-63333</link>
		<dc:creator>Allen Liu</dc:creator>
		<pubDate>Tue, 13 Dec 2011 01:40:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-63333</guid>
		<description>Sorry, I&#039;m very familiar with VBScript.  If you are working with ASP.NET, you should be able to use the JavaScript and HTML code as is.

Allen</description>
		<content:encoded><![CDATA[<p>Sorry, I&#8217;m very familiar with VBScript.  If you are working with ASP.NET, you should be able to use the JavaScript and HTML code as is.</p>
<p>Allen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lokki</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-62862</link>
		<dc:creator>Lokki</dc:creator>
		<pubDate>Sun, 11 Dec 2011 17:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-62862</guid>
		<description>Hi, It&#039;s perfect sample and help.I want to thank you.
If its possible can you give example how to get textarea data with vbscript asp? &quot; + FPL + &quot;&quot;  Best regards.</description>
		<content:encoded><![CDATA[<p>Hi, It&#8217;s perfect sample and help.I want to thank you.<br />
If its possible can you give example how to get textarea data with vbscript asp? &#8221; + FPL + &#8220;&#8221;  Best regards.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Liu</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-61104</link>
		<dc:creator>Allen Liu</dc:creator>
		<pubDate>Wed, 07 Dec 2011 09:05:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-61104</guid>
		<description>Hi Nita,

You can have the extra dropdown menus &quot;hidden&quot; with the display attribute set to none.  If a user pushes the &quot;Add Item&quot; button, you can simply change the CSS of the dropdown menus via JavaScript to make the visible.

Allen</description>
		<content:encoded><![CDATA[<p>Hi Nita,</p>
<p>You can have the extra dropdown menus &#8220;hidden&#8221; with the display attribute set to none.  If a user pushes the &#8220;Add Item&#8221; button, you can simply change the CSS of the dropdown menus via JavaScript to make the visible.</p>
<p>Allen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nita</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-60452</link>
		<dc:creator>Nita</dc:creator>
		<pubDate>Mon, 05 Dec 2011 18:30:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-60452</guid>
		<description>Great help. But I see it can not be used to add a dropdown menu itself? 
I have two drop down menus int a form that provide options for two different kinds of specifications of a product item. I want to be able to have an &quot;Add Item&quot; option for users who want more than one product, but each with different specifications. So I basically need the &quot;Add Item&quot; button to generate two or more extra dropdown menus with the original data in them, for a new item. How can I do this?</description>
		<content:encoded><![CDATA[<p>Great help. But I see it can not be used to add a dropdown menu itself?<br />
I have two drop down menus int a form that provide options for two different kinds of specifications of a product item. I want to be able to have an &#8220;Add Item&#8221; option for users who want more than one product, but each with different specifications. So I basically need the &#8220;Add Item&#8221; button to generate two or more extra dropdown menus with the original data in them, for a new item. How can I do this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Milin</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-55073</link>
		<dc:creator>Milin</dc:creator>
		<pubDate>Mon, 21 Nov 2011 07:17:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-55073</guid>
		<description>Thanks Bro...........</description>
		<content:encoded><![CDATA[<p>Thanks Bro&#8230;&#8230;&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Liu</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-48271</link>
		<dc:creator>Allen Liu</dc:creator>
		<pubDate>Sat, 22 Oct 2011 09:09:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-48271</guid>
		<description>None! Feel free to use it however you like :)</description>
		<content:encoded><![CDATA[<p>None! Feel free to use it however you like :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mia</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-48182</link>
		<dc:creator>Mia</dc:creator>
		<pubDate>Fri, 21 Oct 2011 19:59:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-48182</guid>
		<description>What&#039;s the licensing for your code?</description>
		<content:encoded><![CDATA[<p>What&#8217;s the licensing for your code?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lbfromla</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-46424</link>
		<dc:creator>lbfromla</dc:creator>
		<pubDate>Wed, 12 Oct 2011 09:11:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-46424</guid>
		<description>I&#039;m very grateful for this clear and coherent explanation!
-lbfromla</description>
		<content:encoded><![CDATA[<p>I&#8217;m very grateful for this clear and coherent explanation!<br />
-lbfromla</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: roger</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-45455</link>
		<dc:creator>roger</dc:creator>
		<pubDate>Fri, 07 Oct 2011 09:31:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-45455</guid>
		<description>nice job bro, I&#039;ve been searching for this before now i found it. thanks a lot</description>
		<content:encoded><![CDATA[<p>nice job bro, I&#8217;ve been searching for this before now i found it. thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Liu</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-44782</link>
		<dc:creator>Allen Liu</dc:creator>
		<pubDate>Sun, 02 Oct 2011 08:28:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-44782</guid>
		<description>I am currently learning ASP.NET MVC3. If that is what you are using, you can simply have a submit button with the form action set to the &quot;/controller/action&quot; (assuming you did not change the default routing). There is a bit more to this though like having your action use FormCollection.  Read here for more details:

http://stackoverflow.com/questions/5088450/simple-mvc3-question-how-to-retreive-form-values-from-httppost-dictionary-or

Allen</description>
		<content:encoded><![CDATA[<p>I am currently learning ASP.NET MVC3. If that is what you are using, you can simply have a submit button with the form action set to the &#8220;/controller/action&#8221; (assuming you did not change the default routing). There is a bit more to this though like having your action use FormCollection.  Read here for more details:</p>
<p><a href="http://stackoverflow.com/questions/5088450/simple-mvc3-question-how-to-retreive-form-values-from-httppost-dictionary-or" rel="nofollow">http://stackoverflow.com/questions/5088450/simple-mvc3-question-how-to-retreive-form-values-from-httppost-dictionary-or</a></p>
<p>Allen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: luther</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-44631</link>
		<dc:creator>luther</dc:creator>
		<pubDate>Fri, 30 Sep 2011 17:35:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-44631</guid>
		<description>Would you happen to know how to send the form input info with ASP?</description>
		<content:encoded><![CDATA[<p>Would you happen to know how to send the form input info with ASP?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sumesh</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-43968</link>
		<dc:creator>Sumesh</dc:creator>
		<pubDate>Fri, 23 Sep 2011 08:04:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-43968</guid>
		<description>Hi. Nice work.</description>
		<content:encoded><![CDATA[<p>Hi. Nice work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-43287</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 15 Sep 2011 16:37:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-43287</guid>
		<description>review hiding div tags, and write the fields, but hide the div tags if checked=&#039;checked&#039;</description>
		<content:encoded><![CDATA[<p>review hiding div tags, and write the fields, but hide the div tags if checked=&#8217;checked&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: axl163</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-42940</link>
		<dc:creator>axl163</dc:creator>
		<pubDate>Mon, 12 Sep 2011 15:32:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-42940</guid>
		<description>Hi Ramesh,
You can store session information via cookies.  That way you can first look for the cookies and read the information off of that.  When a user creates a new input element, that information of course will have to be saved to a cookie.

Cookies are always stored in name/value pairs.  Depending on how simple your form is, it can simple be the number of inputs that the user has added.  When a user uses the back button, your CGI script would first look for the cookie.  If the cookie exist, read the number of inputs and create them.  If not, start with a fresh form.  This is a pretty simple case.

Here is some more information on creating/using cookies via CGI::Cookie:

http://perldoc.perl.org/CGI/Cookie.html

I hope this helps.

Allen</description>
		<content:encoded><![CDATA[<p>Hi Ramesh,<br />
You can store session information via cookies.  That way you can first look for the cookies and read the information off of that.  When a user creates a new input element, that information of course will have to be saved to a cookie.</p>
<p>Cookies are always stored in name/value pairs.  Depending on how simple your form is, it can simple be the number of inputs that the user has added.  When a user uses the back button, your CGI script would first look for the cookie.  If the cookie exist, read the number of inputs and create them.  If not, start with a fresh form.  This is a pretty simple case.</p>
<p>Here is some more information on creating/using cookies via CGI::Cookie:</p>
<p><a href="http://perldoc.perl.org/CGI/Cookie.html" rel="nofollow">http://perldoc.perl.org/CGI/Cookie.html</a></p>
<p>I hope this helps.</p>
<p>Allen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramesh</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-42928</link>
		<dc:creator>Ramesh</dc:creator>
		<pubDate>Mon, 12 Sep 2011 11:59:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-42928</guid>
		<description>Hello,
Thanks for sharing this wonderful tutorial.
I have a question, I use Java script in CGI, I create dynamic controls using java script. After proceeding to next page and when the user hits &quot;back button&quot; the controls (created dynamically) are gone. I have seen some of your comments related to this problem, but those are with php, but here I am using cgi. could you please enlighten me?

Thanks
Ramesh</description>
		<content:encoded><![CDATA[<p>Hello,<br />
Thanks for sharing this wonderful tutorial.<br />
I have a question, I use Java script in CGI, I create dynamic controls using java script. After proceeding to next page and when the user hits &#8220;back button&#8221; the controls (created dynamically) are gone. I have seen some of your comments related to this problem, but those are with php, but here I am using cgi. could you please enlighten me?</p>
<p>Thanks<br />
Ramesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SteveD</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-2/#comment-41841</link>
		<dc:creator>SteveD</dc:creator>
		<pubDate>Thu, 01 Sep 2011 13:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-41841</guid>
		<description>Thanks, this puts me on the right track for another project that I&#039;m planning.  Can anyone show a simple example of how to display another textfield based on a checkbox being selected?  An example would be to allow a visitor to add their cell phone number.  If the checkbox is not clicked the Cell Phone field is not displayed on the form, if it is, the field is displayed.  I&#039;m actually planning to use this functinality where a visitor has multiple addresses but only the primary would be displayed if they only had one address.

Thanks for any examples that can be provided.</description>
		<content:encoded><![CDATA[<p>Thanks, this puts me on the right track for another project that I&#8217;m planning.  Can anyone show a simple example of how to display another textfield based on a checkbox being selected?  An example would be to allow a visitor to add their cell phone number.  If the checkbox is not clicked the Cell Phone field is not displayed on the form, if it is, the field is displayed.  I&#8217;m actually planning to use this functinality where a visitor has multiple addresses but only the primary would be displayed if they only had one address.</p>
<p>Thanks for any examples that can be provided.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arvind ojha</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-41081</link>
		<dc:creator>Arvind ojha</dc:creator>
		<pubDate>Wed, 24 Aug 2011 06:59:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-41081</guid>
		<description>thanx i was very useful for mine........</description>
		<content:encoded><![CDATA[<p>thanx i was very useful for mine&#8230;&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: charm</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-38093</link>
		<dc:creator>charm</dc:creator>
		<pubDate>Sat, 23 Jul 2011 06:39:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-38093</guid>
		<description>Hi there!! Thanks for the snippet. It&#039;s very useful to me!! Thanks a lot!!! :)</description>
		<content:encoded><![CDATA[<p>Hi there!! Thanks for the snippet. It&#8217;s very useful to me!! Thanks a lot!!! :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Liu</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-37174</link>
		<dc:creator>Allen Liu</dc:creator>
		<pubDate>Wed, 13 Jul 2011 17:50:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-37174</guid>
		<description>Hi Barry,

The following should work but I have not tested it:

&lt;pre lang=&quot;javascript&quot;&gt;
var counter = 1;
var limit = 3;
function addInput(divName){
     if (counter == limit)  {
          alert(&quot;You have reached the limit of adding &quot; + counter + &quot; inputs&quot;);
     }
     else {
          var newdiv = document.createElement(&#039;div&#039;);
          newdiv.innerHTML = &quot;Entry &quot; + (counter + 1) + &quot; &lt;br&gt;&lt;input id=&#039;input_&quot;+counter+&quot;&#039; type=&#039;text&#039; name=&#039;myInputs[]&#039;&gt;&quot;;
          document.getElementById(divName).appendChild(newdiv);
          counter++;

// give focus to the newly added input
document.getElementById(&quot;input_&quot;+counter).focus();
     }
}
&lt;/pre&gt;

I hope this helps.

Allen</description>
		<content:encoded><![CDATA[<p>Hi Barry,</p>
<p>The following should work but I have not tested it:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> counter <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> limit <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> addInput<span style="color: #009900;">&#40;</span>divName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>counter <span style="color: #339933;">==</span> limit<span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
          <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;You have reached the limit of adding &quot;</span> <span style="color: #339933;">+</span> counter <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; inputs&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
     <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #003366; font-weight: bold;">var</span> newdiv <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          newdiv.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Entry &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>counter <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; &lt;br&gt;&lt;input id='input_&quot;</span><span style="color: #339933;">+</span>counter<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;' type='text' name='myInputs[]'&gt;&quot;</span><span style="color: #339933;">;</span>
          document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>divName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>newdiv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          counter<span style="color: #339933;">++;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// give focus to the newly added input</span>
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input_&quot;</span><span style="color: #339933;">+</span>counter<span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</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;">&#125;</span></pre></div></div>

<p>I hope this helps.</p>
<p>Allen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barry Hunt</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-37150</link>
		<dc:creator>Barry Hunt</dc:creator>
		<pubDate>Wed, 13 Jul 2011 10:16:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-37150</guid>
		<description>This example is working fine for me but I cannot work out how to set the focus onto the newly created element in the form.
Is there some way to do this ?.
My project involves barcode entry from a scanner into each element without the need for keyboard or mouse - the idea is that the user will scan repeated barcodes (each barcode will be followed by a simulated enter key) until they scan a code which signifies &quot;done&quot; then the form will be submitted.</description>
		<content:encoded><![CDATA[<p>This example is working fine for me but I cannot work out how to set the focus onto the newly created element in the form.<br />
Is there some way to do this ?.<br />
My project involves barcode entry from a scanner into each element without the need for keyboard or mouse &#8211; the idea is that the user will scan repeated barcodes (each barcode will be followed by a simulated enter key) until they scan a code which signifies &#8220;done&#8221; then the form will be submitted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Liu</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-37101</link>
		<dc:creator>Allen Liu</dc:creator>
		<pubDate>Tue, 12 Jul 2011 21:25:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-37101</guid>
		<description>Hi Bryan,

Can you give me the URL to your form?  That would allow me to quickly see where the issue is.

Thanks,

Allen</description>
		<content:encoded><![CDATA[<p>Hi Bryan,</p>
<p>Can you give me the URL to your form?  That would allow me to quickly see where the issue is.</p>
<p>Thanks,</p>
<p>Allen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bryan</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-37096</link>
		<dc:creator>bryan</dc:creator>
		<pubDate>Tue, 12 Jul 2011 18:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-37096</guid>
		<description>good day i have used the code above to add form on my system, problem is when im passing the page to my php form it wasnt displaying the array 

here is my php code:

if(isset($_POST[&#039;submit&#039;])) 
{
	$myInputs = $_POST[&quot;myInputs&quot;];
	foreach ($myInputs as $eachInput) {
     echo $eachInput . &quot;&quot;;
}
}</description>
		<content:encoded><![CDATA[<p>good day i have used the code above to add form on my system, problem is when im passing the page to my php form it wasnt displaying the array </p>
<p>here is my php code:</p>
<p>if(isset($_POST['submit']))<br />
{<br />
	$myInputs = $_POST["myInputs"];<br />
	foreach ($myInputs as $eachInput) {<br />
     echo $eachInput . &#8220;&#8221;;<br />
}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Liu</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-35639</link>
		<dc:creator>Allen Liu</dc:creator>
		<pubDate>Wed, 22 Jun 2011 15:40:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-35639</guid>
		<description>Thanks for the comment =)

Allen</description>
		<content:encoded><![CDATA[<p>Thanks for the comment =)</p>
<p>Allen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-35638</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 22 Jun 2011 15:22:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-35638</guid>
		<description>nice work  and thanks a lot for it dude!!!!!!!!!</description>
		<content:encoded><![CDATA[<p>nice work  and thanks a lot for it dude!!!!!!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brett</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-34422</link>
		<dc:creator>brett</dc:creator>
		<pubDate>Mon, 06 Jun 2011 18:00:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-34422</guid>
		<description>Thanks for the help. This was the only website that helped me quick enough.

Thanks,

Brett</description>
		<content:encoded><![CDATA[<p>Thanks for the help. This was the only website that helped me quick enough.</p>
<p>Thanks,</p>
<p>Brett</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javid</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-33520</link>
		<dc:creator>Javid</dc:creator>
		<pubDate>Thu, 26 May 2011 11:05:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-33520</guid>
		<description>thanks ... this was really useful .
i appreciate it .</description>
		<content:encoded><![CDATA[<p>thanks &#8230; this was really useful .<br />
i appreciate it .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-30923</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Fri, 15 Apr 2011 18:01:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-30923</guid>
		<description>My goodness.... 10 hours wasted trying everything and the solution was right here... and such a simple one at that. Moving the form up on the page worked. Thanks a billion.</description>
		<content:encoded><![CDATA[<p>My goodness&#8230;. 10 hours wasted trying everything and the solution was right here&#8230; and such a simple one at that. Moving the form up on the page worked. Thanks a billion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Liu</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-30597</link>
		<dc:creator>Allen Liu</dc:creator>
		<pubDate>Sun, 10 Apr 2011 16:20:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-30597</guid>
		<description>Hi Wondering Coder,

Repopulating your form with information from a database is certainly possible but well beyond what is shown here.  I can go through a high level discussion of what I would do though.  

If a user presses the Update button, I would do a form submit with the necessary information to collect the right pieces of data from the database.  I would then load up a new page with both the form and data already prefilled.

I apologize if this does not help but it is difficult without knowing which language you are using to do this.

Allen</description>
		<content:encoded><![CDATA[<p>Hi Wondering Coder,</p>
<p>Repopulating your form with information from a database is certainly possible but well beyond what is shown here.  I can go through a high level discussion of what I would do though.  </p>
<p>If a user presses the Update button, I would do a form submit with the necessary information to collect the right pieces of data from the database.  I would then load up a new page with both the form and data already prefilled.</p>
<p>I apologize if this does not help but it is difficult without knowing which language you are using to do this.</p>
<p>Allen</p>
]]></content:encoded>
	</item>
</channel>
</rss>

