<html>
<head>
<title></title>
</head>
<body>
<div>
<input type = "text" id="test1" />
<input type = "text" id="test2" />
<input type = "text" id="test3" />
<input type = "text" id="test4" />
</div>
<div>
<input type = "text" id="test111" />
<input type = "text" id="test222" />
<input type = "text" id="test333" />
<input type = "text" id="test444" />
</div>
</body>
<script language = "javascript">
var elems = document.getElementsByTagName('input');
for(var i=0; i< elems.length; i++)
{
alert(elems[i].type);
}
</script>
</html>
//hope this will helps you
Please don't forget to "Mark This As Answer" if this post Helped you.
Sincerely,
ABHI
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question.
Marked as answer by deostroll on Nov 18, 2008 10:26 AM
Can you please mark as answer , which may helps the others for finding the correct answer
thanks
Sincerely,
ABHI
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question.
deostroll
Member
517 Points
375 Posts
get all textboxes via javascript.
Nov 18, 2008 03:46 AM|LINK
I've tried the following:
var elems = document.getElementsByTagName('input'); for(obj in elems) { alert(obj.type); }Here I was trying to find out if the input field was 'text' or 'hidden', etc. I always seem to get undefined in the alert box.
cninjas
Contributor
4868 Points
851 Posts
Re: get all textboxes via javascript.
Nov 18, 2008 04:11 AM|LINK
hi try this....
{
var boxes = document.getElementsByTagName("INPUT");
for(var i = 0; i < boxes.length; i++)
{
// if(boxes[i].type == 'text')
alert(boxes[i].type);
//boxes[i].readOnly=true;
};
};
Niranjan
mooncoder
Participant
955 Points
178 Posts
Re: get all textboxes via javascript.
Nov 18, 2008 04:20 AM|LINK
<html>
<head>
<title></title>
</head>
<body>
<div>
<input type = "text" id="test1" />
<input type = "text" id="test2" />
<input type = "text" id="test3" />
<input type = "text" id="test4" />
</div>
<div>
<input type = "text" id="test111" />
<input type = "text" id="test222" />
<input type = "text" id="test333" />
<input type = "text" id="test444" />
</div>
</body>
<script language = "javascript">
var elems = document.getElementsByTagName('input');
for(var i=0; i< elems.length; i++)
{
alert(elems[i].type);
}
</script>
</html>
//hope this will helps you
Please don't forget to "Mark This As Answer" if this post Helped you.
ABHI
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question.
deostroll
Member
517 Points
375 Posts
Re: get all textboxes via javascript.
Nov 18, 2008 05:35 AM|LINK
Thanx this works. Wonder why the for...in... didn't work tho.
Macolele
Member
320 Points
116 Posts
Re: get all textboxes via javascript.
Nov 18, 2008 06:03 AM|LINK
Beacause for...in get all properties, not all elements.
mooncoder
Participant
955 Points
178 Posts
Re: get all textboxes via javascript.
Nov 18, 2008 07:27 AM|LINK
Hi,
Can you please mark as answer , which may helps the others for finding the correct answer
thanks
ABHI
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question.