<?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 and Ideas for any Web Developer</description>
	<lastBuildDate>Sat, 17 Jul 2010 11:08:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Kevin</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-11443</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Mon, 15 Feb 2010 16:09:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-11443</guid>
		<description>Great Tutorial!! I was doing it in a roundabout way of creating ids -textarea1,2,... instead of using textarea[]... Good thing I found about this easy way ^_^&#039;&#039;...also, Thanks to Matthew Atkins for pointing out that problem with the form tag . Got me a headache for 2 days...I wouldn&#039;t have thought about looking for the problem in the form tag -_- . Thanks a looot guys :)</description>
		<content:encoded><![CDATA[<p>Great Tutorial!! I was doing it in a roundabout way of creating ids -textarea1,2,&#8230; instead of using textarea[]&#8230; Good thing I found about this easy way ^_^&#8221;&#8230;also, Thanks to Matthew Atkins for pointing out that problem with the form tag . Got me a headache for 2 days&#8230;I wouldn&#8217;t have thought about looking for the problem in the form tag -_- . Thanks a looot guys :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: domina</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-10459</link>
		<dc:creator>domina</dc:creator>
		<pubDate>Fri, 15 Jan 2010 09:33:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-10459</guid>
		<description>i copied all of your codes..
but this part is not running:

$myInputs = $_POST[&quot;myInputs&quot;];
foreach ($myInputs as $eachInput)
    {
     echo $eachInput . &quot;&quot;;



and got this error:
Warning: Invalid argument supplied for foreach() in E:\programfiles\xampp\htdocs\trial\index.php on line 23


please tell me what&#039;s the problem..
you can email me at:
gondong.domina@yahoo.com

please do help..
tnx.</description>
		<content:encoded><![CDATA[<p>i copied all of your codes..<br />
but this part is not running:</p>
<p>$myInputs = $_POST["myInputs"];<br />
foreach ($myInputs as $eachInput)<br />
    {<br />
     echo $eachInput . &#8220;&#8221;;</p>
<p>and got this error:<br />
Warning: Invalid argument supplied for foreach() in E:\programfiles\xampp\htdocs\trial\index.php on line 23</p>
<p>please tell me what&#8217;s the problem..<br />
you can email me at:<br />
<a href="mailto:gondong.domina@yahoo.com">gondong.domina@yahoo.com</a></p>
<p>please do help..<br />
tnx.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Web Design Rob</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-7994</link>
		<dc:creator>Web Design Rob</dc:creator>
		<pubDate>Thu, 05 Nov 2009 23:55:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-7994</guid>
		<description>I wrote an article on exactly how to do this :) 

http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/</description>
		<content:encoded><![CDATA[<p>I wrote an article on exactly how to do this :) </p>
<p><a href="http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/" rel="nofollow">http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael M</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-7921</link>
		<dc:creator>Michael M</dc:creator>
		<pubDate>Tue, 03 Nov 2009 20:07:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-7921</guid>
		<description>How do I control the output of the script when I have it creating mulitple fields?

Example: If I&#039;m asking for  ^user^&#124;^url^&#124;^location^ and these field get mulitplied based on the number of desired submition my output ends up looking like this.

John Mike Tom&#124;www.test.com www.five.com www.four.com&#124;Dallas New York Paris

The desired output should look like this
 John&#124;www.test.com&#124;Dallas
 Mike&#124;www.five.com&#124;New York
  Tom&#124;www.four.com&#124;Paris

How do I do this?</description>
		<content:encoded><![CDATA[<p>How do I control the output of the script when I have it creating mulitple fields?</p>
<p>Example: If I&#8217;m asking for  ^user^|^url^|^location^ and these field get mulitplied based on the number of desired submition my output ends up looking like this.</p>
<p>John Mike Tom|www.test.com <a href="http://www.five.com" rel="nofollow">http://www.five.com</a> <a href="http://www.four.com" rel="nofollow">http://www.four.com</a>|Dallas New York Paris</p>
<p>The desired output should look like this<br />
 John|www.test.com|Dallas<br />
 Mike|www.five.com|New York<br />
  Tom|www.four.com|Paris</p>
<p>How do I do this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Meghan</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-7338</link>
		<dc:creator>Meghan</dc:creator>
		<pubDate>Sat, 10 Oct 2009 18:31:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-7338</guid>
		<description>and here is the HTML code





			 First Name: 
          			
         			 &lt;a&gt;&lt;/a&gt;
			
			 Last Name: 
        			
       			
     			
	
	
	Item ID:  Quantity:  Price: $ 
	
		      
      			 

</description>
		<content:encoded><![CDATA[<p>and here is the HTML code</p>
<p>			 First Name: </p>
<p>         			 <a></a></p>
<p>			 Last Name: </p>
<p>	Item ID:  Quantity:  Price: $</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Meghan</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-7337</link>
		<dc:creator>Meghan</dc:creator>
		<pubDate>Sat, 10 Oct 2009 18:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-7337</guid>
		<description>I have to create a form which the user can add a form field, which will be &quot;Item ID, Quantity, and Price&quot; and then when the user has entered all the information, they can press &quot;process order&quot; and an alert box will pop up saying the total order. 

I cant figure out how to get the process order function to multiply the quantity and price of each line seperatly, and then add them together.. It will only do it for one line, the parentnode, i think its because i cant figure out how to give the elements that are created a unique ID. 

 here is the code i have so far, any help would be greatly appreciated





 



	function addKeyword()
	{
		var keywordObj = document.getElementById(&quot;keywordForm&quot;);
		var count = document.getElementById(&quot;keywordCount&quot;).value;
		var newObj = document.createElement(&quot;div&quot;);
		newObj.setAttribute(&quot;id&quot;, &quot;keywordInput_&quot; + count);
		newObj.innerHTML = &quot;Item ID: &quot; + &quot; &quot; +
		&quot;Quantity: &quot; + &quot; &quot; + &quot;Price: $ &quot; + &quot; &quot; + &quot; &quot;;
		keywordObj.appendChild(newObj);
		count++;
		document.getElementById(&quot;keywordCount&quot;).value = count;
	}
 
 
	function delKeyword(i)
	{
		var div = document.getElementById(&quot;keywordForm&quot;);
		var delDiv = document.getElementById(&quot;keywordInput_&quot; + i);
		div.removeChild(delDiv);
	}




    
          function ProcessOrder()
            {
		var strOutput;
		var Quantity;
		var Price;
		var TotalPrice;

		Quantity = document.getElementById(&#039;txtQuantity&#039;).value;
		Price = document.getElementById(&#039;txtPrice&#039;).value;
		TotalPrice = Quantity * Price;
		
		strOutput = &quot;Total Price: $&quot; + TotalPrice
                
		alert(strOutput);
            }
      
 
 
 
 




			 First Name: 
          			
         			 &lt;a&gt;&lt;/a&gt;
			
			 Last Name: 
        			
       			
     			
	
	
	Item ID:  Quantity:  Price: $ 
	
		      
      			 


</description>
		<content:encoded><![CDATA[<p>I have to create a form which the user can add a form field, which will be &#8220;Item ID, Quantity, and Price&#8221; and then when the user has entered all the information, they can press &#8220;process order&#8221; and an alert box will pop up saying the total order. </p>
<p>I cant figure out how to get the process order function to multiply the quantity and price of each line seperatly, and then add them together.. It will only do it for one line, the parentnode, i think its because i cant figure out how to give the elements that are created a unique ID. </p>
<p> here is the code i have so far, any help would be greatly appreciated</p>
<p>	function addKeyword()<br />
	{<br />
		var keywordObj = document.getElementById(&#8220;keywordForm&#8221;);<br />
		var count = document.getElementById(&#8220;keywordCount&#8221;).value;<br />
		var newObj = document.createElement(&#8220;div&#8221;);<br />
		newObj.setAttribute(&#8220;id&#8221;, &#8220;keywordInput_&#8221; + count);<br />
		newObj.innerHTML = &#8220;Item ID: &#8221; + &#8221; &#8221; +<br />
		&#8220;Quantity: &#8221; + &#8221; &#8221; + &#8220;Price: $ &#8221; + &#8221; &#8221; + &#8221; &#8220;;<br />
		keywordObj.appendChild(newObj);<br />
		count++;<br />
		document.getElementById(&#8220;keywordCount&#8221;).value = count;<br />
	}</p>
<p>	function delKeyword(i)<br />
	{<br />
		var div = document.getElementById(&#8220;keywordForm&#8221;);<br />
		var delDiv = document.getElementById(&#8220;keywordInput_&#8221; + i);<br />
		div.removeChild(delDiv);<br />
	}</p>
<p>          function ProcessOrder()<br />
            {<br />
		var strOutput;<br />
		var Quantity;<br />
		var Price;<br />
		var TotalPrice;</p>
<p>		Quantity = document.getElementById(&#8216;txtQuantity&#8217;).value;<br />
		Price = document.getElementById(&#8216;txtPrice&#8217;).value;<br />
		TotalPrice = Quantity * Price;</p>
<p>		strOutput = &#8220;Total Price: $&#8221; + TotalPrice</p>
<p>		alert(strOutput);<br />
            }</p>
<p>			 First Name: </p>
<p>         			 <a></a></p>
<p>			 Last Name: </p>
<p>	Item ID:  Quantity:  Price: $</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Random Randy Ramblings &#124; DOM-inating dynamic form elements</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-7013</link>
		<dc:creator>Random Randy Ramblings &#124; DOM-inating dynamic form elements</dc:creator>
		<pubDate>Sun, 27 Sep 2009 16:50:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-7013</guid>
		<description>[...] thanks to my two sources for parts of this exercise here and [...]</description>
		<content:encoded><![CDATA[<p>[...] thanks to my two sources for parts of this exercise here and [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: satheesh</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-6145</link>
		<dc:creator>satheesh</dc:creator>
		<pubDate>Thu, 27 Aug 2009 11:44:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-6145</guid>
		<description>how can i add form elements in dynamically created form</description>
		<content:encoded><![CDATA[<p>how can i add form elements in dynamically created form</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5951</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Tue, 18 Aug 2009 22:36:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5951</guid>
		<description>A short article I wrote explaining how to retreieve multiple values when you add more than one field each time - http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/</description>
		<content:encoded><![CDATA[<p>A short article I wrote explaining how to retreieve multiple values when you add more than one field each time &#8211; <a href="http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/" rel="nofollow">http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5918</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Mon, 17 Aug 2009 18:51:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5918</guid>
		<description>You could do that a lot neatter using JQuery and ther append() fucntion. Or even better better, simple use clone() on the parrent element :)</description>
		<content:encoded><![CDATA[<p>You could do that a lot neatter using JQuery and ther append() fucntion. Or even better better, simple use clone() on the parrent element :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5917</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Mon, 17 Aug 2009 18:50:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5917</guid>
		<description>Hi, 

Again, this is simply looping through a series of associative arrays. E.g. you&#039;d need to name each field as an array - field1[] , field2[] etc etc and then loop through you&#039;re post data sequentially E.g - say you were adding 2 fields each time - name and email. 

if (isset($_POST[&#039;cname&#039;])) {
   
    for ( $i=0; $i&lt;count($_POST[&#039;cname&#039;]); $i++) {
							        $contactname  = $_POST[&#039;cname&#039;][$i];
    $conatctemail = $_POST[&#039;cemail&#039;][$i];

    }

}



I&#039;ll be posting a tutorial on my site how to do this, as it took me a while to find out myself :) 

Once I&#039;ve made the tutorial I&#039;ll post a quick link here if it&#039;s ok, as a lot of people seem to be asking the same thing :)</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>Again, this is simply looping through a series of associative arrays. E.g. you&#8217;d need to name each field as an array &#8211; field1[] , field2[] etc etc and then loop through you&#8217;re post data sequentially E.g &#8211; say you were adding 2 fields each time &#8211; name and email. </p>
<p>if (isset($_POST['cname'])) {</p>
<p>    for ( $i=0; $i&lt;count($_POST['cname']); $i++) {<br />
							        $contactname  = $_POST['cname'][$i];<br />
    $conatctemail = $_POST['cemail'][$i];</p>
<p>    }</p>
<p>}</p>
<p>I&#8217;ll be posting a tutorial on my site how to do this, as it took me a while to find out myself :) </p>
<p>Once I&#8217;ve made the tutorial I&#8217;ll post a quick link here if it&#8217;s ok, as a lot of people seem to be asking the same thing :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5916</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Mon, 17 Aug 2009 18:45:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5916</guid>
		<description>@Pumpkin: You&#039;ll need to loop through an associative array for your chosen post value array. I have posted a rather extensive tutorial on my blog on how to do this using JQuery and PHP: see http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/. 

However, if you&#039;re familiar with PHP you&#039;d simply use a key value approach. You need to name each dynamically added field say &#039;fields[]&#039; so PHP reads the POSTS data as an array E.g.

foreach ( $_POST[&#039;fields&#039;] as $key=&gt;$value ) {
 echo $value , &quot;&quot;;
}</description>
		<content:encoded><![CDATA[<p>@Pumpkin: You&#8217;ll need to loop through an associative array for your chosen post value array. I have posted a rather extensive tutorial on my blog on how to do this using JQuery and PHP: see <a href="http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/" rel="nofollow">http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/</a>. </p>
<p>However, if you&#8217;re familiar with PHP you&#8217;d simply use a key value approach. You need to name each dynamically added field say &#8216;fields[]&#8216; so PHP reads the POSTS data as an array E.g.</p>
<p>foreach ( $_POST['fields'] as $key=&gt;$value ) {<br />
 echo $value , &#8220;&#8221;;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nasim</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5865</link>
		<dc:creator>nasim</dc:creator>
		<pubDate>Sat, 15 Aug 2009 14:54:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5865</guid>
		<description>hello
after thanking you for the great tutorial i wanted to ask you a question about a case which i faced when i tried to add multiple items to form each time,the problem is that all added items go right after the first existing element in the div section of html form while i need them to be added after the last element of my div section of html...any help?</description>
		<content:encoded><![CDATA[<p>hello<br />
after thanking you for the great tutorial i wanted to ask you a question about a case which i faced when i tried to add multiple items to form each time,the problem is that all added items go right after the first existing element in the div section of html form while i need them to be added after the last element of my div section of html&#8230;any help?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Knix</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5472</link>
		<dc:creator>Knix</dc:creator>
		<pubDate>Thu, 30 Jul 2009 14:29:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5472</guid>
		<description>Hi Pumpkin,

Can you please post the html of your form?  That will definitely give me some clues.

Knix</description>
		<content:encoded><![CDATA[<p>Hi Pumpkin,</p>
<p>Can you please post the html of your form?  That will definitely give me some clues.</p>
<p>Knix</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pumpkin</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5382</link>
		<dc:creator>Pumpkin</dc:creator>
		<pubDate>Mon, 27 Jul 2009 05:02:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5382</guid>
		<description>HI, I am new to add form elements dynamically.

From now on, I add rows successfully.
However, when i submit the form, i cant get the data which are in the newly add rows.

I try to submit the form by &quot;post&quot; and &quot;get&quot; both method are failed to get the value in the newly added rows..

..
if (isset($_POST[&#039;submit&#039;])) {
	$inputs = $_POST[&quot;inputs&quot;];
	echo $inputs [0];  // &lt;--- original row is ok to output data here!
	echo $inputs [1];
	echo $inputs [2];
	echo $inputs [3];
	echo $inputs [4];
	echo $inputs [5]; // &lt;--- newly added row by pressing the button is FAILED to output data here!
	echo $inputs [6];
}</description>
		<content:encoded><![CDATA[<p>HI, I am new to add form elements dynamically.</p>
<p>From now on, I add rows successfully.<br />
However, when i submit the form, i cant get the data which are in the newly add rows.</p>
<p>I try to submit the form by &#8220;post&#8221; and &#8220;get&#8221; both method are failed to get the value in the newly added rows..</p>
<p>..<br />
if (isset($_POST['submit'])) {<br />
	$inputs = $_POST["inputs"];<br />
	echo $inputs [0];  // &lt;&#8212; original row is ok to output data here!<br />
	echo $inputs [1];<br />
	echo $inputs [2];<br />
	echo $inputs [3];<br />
	echo $inputs [4];<br />
	echo $inputs [5]; // &lt;&#8212; newly added row by pressing the button is FAILED to output data here!<br />
	echo $inputs [6];<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5352</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sun, 26 Jul 2009 02:42:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5352</guid>
		<description>Nice article! I made an extended and more compact version of your idea using JQuery, the article also explains how to save dynamically added form values to a many-many database structure, using mysql/php. See:

http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/</description>
		<content:encoded><![CDATA[<p>Nice article! I made an extended and more compact version of your idea using JQuery, the article also explains how to save dynamically added form values to a many-many database structure, using mysql/php. See:</p>
<p><a href="http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/" rel="nofollow">http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/</a></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-5340</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sat, 25 Jul 2009 15:29:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5340</guid>
		<description>Hi,

How to validate the value of dynamically added form element(i.e textbox1 textbox2 etc.) using javascript.

Thx,
SAN</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>How to validate the value of dynamically added form element(i.e textbox1 textbox2 etc.) using javascript.</p>
<p>Thx,<br />
SAN</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Knix</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5125</link>
		<dc:creator>Knix</dc:creator>
		<pubDate>Fri, 17 Jul 2009 07:31:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5125</guid>
		<description>Hi Andre,

The function can be modified by adding a for loop which creates 3 input fields instead of 1:

&lt;pre lang=&quot;javascript&quot; line=&quot;1&quot;&gt;
function add3Inputs(divName){
    for (i=1; i&lt;=3; i++) {
        var newdiv = document.createElement(&#039;div&#039;);
        newdiv.innerHTML = &quot;Entry &quot; + i + &quot; &lt;br&gt;&lt;input type=&#039;text&#039; name=&#039;myInputs[]&#039;&gt;&quot;;
        document.getElementById(divName).appendChild(newdiv);
    }
}
&lt;/pre&gt;

Please note that this code is not tested but I hope you get the idea.</description>
		<content:encoded><![CDATA[<p>Hi Andre,</p>
<p>The function can be modified by adding a for loop which creates 3 input fields instead of 1:</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="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> add3Inputs<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;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">1</span>; i<span style="color: #339933;">&lt;=</span><span style="color: #CC0000;">3</span>; i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</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>;
        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> i <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; &lt;br&gt;&lt;input type='text' name='myInputs[]'&gt;&quot;</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: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Please note that this code is not tested but I hope you get the idea.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andre</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-5101</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Thu, 16 Jul 2009 10:38:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-5101</guid>
		<description>Thank you so much for the code and the explanations. This is really great! I would really appreciate if anyone could help me with the following: I would like to use this skript but i want the »Add another Input« button to create several input fields at the same time. For better explanation:
When starting i would like to have 3 input fields in a row:
Name &#124; Age &#124; Country
and when the »Add another Input« button is pressed another three field Name &#124; Age &#124; Country row should appear.

Thank you once again,

tm</description>
		<content:encoded><![CDATA[<p>Thank you so much for the code and the explanations. This is really great! I would really appreciate if anyone could help me with the following: I would like to use this skript but i want the »Add another Input« button to create several input fields at the same time. For better explanation:<br />
When starting i would like to have 3 input fields in a row:<br />
Name | Age | Country<br />
and when the »Add another Input« button is pressed another three field Name | Age | Country row should appear.</p>
<p>Thank you once again,</p>
<p>tm</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michal Marianek</title>
		<link>http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/comment-page-1/#comment-4887</link>
		<dc:creator>Michal Marianek</dc:creator>
		<pubDate>Mon, 06 Jul 2009 10:04:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/#comment-4887</guid>
		<description>Hello
Thank you for this code. This is exactly what I was looking for!! I just wanted to ask . Is there possible to add a remove function?  There would be a remove button under each fotm instance so user could add a new ones and/or remove existing ones. It would be great!
Thank you
Michal</description>
		<content:encoded><![CDATA[<p>Hello<br />
Thank you for this code. This is exactly what I was looking for!! I just wanted to ask . Is there possible to add a remove function?  There would be a remove button under each fotm instance so user could add a new ones and/or remove existing ones. It would be great!<br />
Thank you<br />
Michal</p>
]]></content:encoded>
	</item>
</channel>
</rss>
