while calculting the total of gridview cells using javascript getting exception
<p>I am calculating the total of one gridivew cells using javascript and displaying the resul in gridivew
footer. but i am getting this exception
<strong>Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object</strong></p>

<p>Here is my code:</p>

<pre><code>&lt;asp:GridView ID="gv" runat="server" AutoGenerateColumns="false" ShowFooter="true"&gt; 
 &lt;Columns&gt;      
   &lt;asp:TemplateField&gt;
      &lt;ItemTemplate&gt;
         &lt;asp:TextBox ID="TextBox1" runat="server" onkeyup="Calculate('gv')" /&gt;
     &lt;/ItemTemplate&gt;
     &lt;FooterTemplate&gt;
        &lt;asp:TextBox ID="total" runat="server" Text="0" Width="83px"&gt;&lt;/asp:TextBox&gt;
     &lt;/FooterTemplate&gt;
&lt;/Columns&gt;
</code></pre>

<p></p>

<pre><code>&lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js"&gt;&lt;/script&gt;  
&lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.js"&gt;&lt;/script&gt;    
&lt;script type="text/javascript"&gt;
function Calculate(GridView)
{
var total = 0;
var gridview = document.getElementById(GridView);

for ( i = 0; i &lt; gridview.rows.length; i ++)
{
   var node = gridview.rows[i].cells[1].childNodes[1]; //textbox       

   if (node != undefined &amp;&amp; node.type == "text") //check only textbox, ignore empty one
        if (!isNaN(node.value) &amp;&amp; node.value != "") //check for valid number
           total += parseInt(node.value);
}

document.getElementById("total").value = total.toString(); //display
</code></pre>

<p>}
   </p>
