Its very strange condition for me but anchors.length only give total number of anchors when i place script after all anchors tag and when i place before all anchors it gives zero....so i did this but now function lngt() is not returning length of anchors please help me i just stuck..
here is my code
<div class="box">
<script>
var na;
na = lngt();
for(i = 0 ; i < na ; i++)
{
txt = document.anchors[i].innerHTML;
lnk = document.anchors[i].name;
document.write( "<a href='#"+lnk+"'>"+ txt + "</a></br>");
}
</script>
</div>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br /><br/><br/><br/>
<a name="a">anchor 1</a><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br
/><br/><br/><br/>
<a name="b">anchor 2</a><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br
/><br/><br/><br/>
<a name="c">anchor 3</a><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br
/><br/><br/><br/>
<a name="d">anchor 4</a><br/>
<script>
function lngt(){
var nc = document.anchors.length;
return nc;
}
</script>
When i put both script at the end its working fine :/ Thanks in Advance :)