PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
eatspinach
Forum Newbie
Posts: 20 Joined: Mon Apr 20, 2009 8:50 am
Post
by eatspinach » Mon Apr 20, 2009 8:57 am
Hi
I am looking for some code that will count the number of text boxes on my page...
Any Ideas??
Thanks
it2051229
Forum Contributor
Posts: 312 Joined: Tue Dec 25, 2007 8:34 pm
Post
by it2051229 » Mon Apr 20, 2009 9:55 am
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>
eatspinach
Forum Newbie
Posts: 20 Joined: Mon Apr 20, 2009 8:50 am
Post
by eatspinach » Mon Apr 20, 2009 10:19 am
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...