how to count rows in javascript?
<p>refer my below javascript code , how to count rows if i click add form and remove form, my reason is
i want to do something like this :</p>

<p>*so the value will be dynamic when click "add form" the value(from count form) will be increase but when i click remove the value will be decrease.</p>

<pre><code>&lt;?php $totalrow=$count_from_rows_javascript; ?&gt;
&lt;label&gt;Total Row&lt;/label&gt;
&lt;input type="text" name="total_row" id="total_row" value="&lt;?php echo $totalrow; ?&gt;"/&gt;
</code></pre>

<p>My Javascript Code :</p>

<pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;script type="text/javascript"&gt;

(function($){
$countForms = 1;
$.fn.addForms = function(){
if ($countForms == 11 ) {
$("#mybutton").unbind("click");
return;
}
  var myform = "&lt;table&gt;"+
                         "  &lt;tr&gt;"+
                         "     &lt;td&gt;Field A ("+$countForms+"):&lt;/td&gt;"+
                         "     &lt;td&gt;&lt;input type='text' name='fielda["+$countForms+"]'&gt;&lt;/td&gt;"+
                         "     &lt;td&gt;Field B ("+$countForms+"):&lt;/td&gt;"+
                         "     &lt;td&gt;&lt;textarea name='fieldb["+$countForms+"]'&gt;&lt;/textarea&gt;&lt;/td&gt;"+
                         "     &lt;td&gt;&lt;button&gt;remove&lt;/button&gt;&lt;/td&gt;"+
                         "  &lt;/tr&gt;"+
                         "&lt;/table&gt;";

                         myform = $("&lt;div&gt;"+myform+"&lt;/div&gt;");
                         $("button", $(myform)).click(function(){ $(this).parent().parent().remove(); });

                         $(this).append(myform);
                         $countForms++;
          };
    })(jQuery);         

    $(function(){
        $("#mybutton").bind("click", function(){
                $("#container").addForms();
        });
    });

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;button id="mybutton"&gt;add form&lt;/button&gt;
&lt;div id="container"&gt;&lt;/div&gt;
</code></pre>

<p>so any suggestion would be much appreciated! (i'm still newbie in javascript)</p>

<p>Thanks.</p>
