how to find no of div inside a form? and assign the no to a variable for next and previous buttons?
<pre><code>&lt;script language="javascript" type="text/javascript"&gt;

var value1=0;
var total_no_div;
var previous;

function doSwap(val) {

    divs=document.getElementById(form).getElementsByTagName(val);
    document.write(divs);


}


&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="doSwap(0)"&gt;
&lt;form&gt;
&lt;input type="button" id="button" value="previous"  name="previous" onClick="doSwap(this.value);"&gt;
&lt;input type="button" id="button" value="next" name="next" onClick="doSwap(this.value);"&gt;

&lt;!--******************************************************************************--&gt;
&lt;div id="div1"&gt;
&lt;/div&gt;
&lt;div id="div2"&gt;
&lt;/div&gt;

&lt;div id="div3"&gt;
&lt;/div&gt;

&lt;div id="div4"&gt;
&lt;/div&gt;
</code></pre>

<p>here i want to assign a total no div to a variable,and set it to previous and next button for navigation.</p>
