Page 1 of 1
Counting Input Boxes
Posted: Mon Apr 20, 2009 8:57 am
by eatspinach
Hi
I am looking for some code that will count the number of text boxes on my page...
Any Ideas??
Thanks

Re: Counting Input Boxes
Posted: Mon Apr 20, 2009 9:55 am
by it2051229
use javascript...
Code: Select all
<script type='text/javascript'>
int textboxesCount = 0;
window.onload = function()
{
var inputTags = document.getElementsByTagName("input");
for(i = 0; i < inputTags.length; i++)
{
if(inputTags[i].type == "text")
{
textboxesCount++;
}
}
alert("you have " + textboxesCount + " textboxes in your page");
}
</script>
Re: Counting Input Boxes
Posted: Mon Apr 20, 2009 10:19 am
by eatspinach
Thanks Very Much. That worked.
I had to change the line,
int textboxesCount = 0;
to
var textboxesCount = 0;
before it would work but thats great thanks...
