Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine Total Items in an Array

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
What is the easiest way to determine the total items in an array?

Thanks,

Michael42

 
use ".length" object method, it will return the length of an array

Code:
<SCRIPT LANGUAGE=&quot;JavaScript&quot; TYPE=&quot;text/javascript&quot;>
<!--
function funcArrayLength(){
var str = &quot;1,2,3,4,5,6,8&quot;;
	arr = str.split(&quot;,&quot;);
	
	alert(arr.length);
}
//-->
</SCRIPT>
<form name=&quot;form1&quot; >
<input type=button onclick=&quot;funcArrayLength()&quot;>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top