|
-
May 27th, 2007, 11:16 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Get all child objects
Hey guys.
How to get all child objects inside of an object.
For example; I have a form and I want to get all the textfields, checkboxes, radio buttons, buttons, etc. with their names and values.
How to do it?
-
May 28th, 2007, 12:00 AM
#2
Hyperactive Member
Re: Get all child objects
 Originally Posted by eSPiYa
Hey guys.
How to get all child objects inside of an object.
For example; I have a form and I want to get all the textfields, checkboxes, radio buttons, buttons, etc. with their names and values.
How to do it?
Uhm....
Let me guess....
document.form[0].getElementsbyTagName("input").name
document.form[0].getElementsbyTagName("input").value
Rate Me! Rate Me! Rate Me!
Time to fly.
Copyright GraysonSoft Inc. 2007
-
May 28th, 2007, 12:10 AM
#3
Thread Starter
Fanatic Member
Re: Get all child objects
Maybe it is a good alternative.
How about getting child elements regardless of tag?
-
May 28th, 2007, 12:13 AM
#4
Hyperactive Member
Re: Get all child objects
 Originally Posted by eSPiYa
Maybe it is a good alternative.
How about getting child elements regardless of tag?
Uhm....
Let me guess....
document.form[0].all.name
document.form[0].all.value
Is that close enough?
Rate Me! Rate Me! Rate Me!
Time to fly.
Copyright GraysonSoft Inc. 2007
-
May 28th, 2007, 12:32 AM
#5
Thread Starter
Fanatic Member
Re: Get all child objects
Is there a property/function all?
-
May 28th, 2007, 12:39 AM
#6
Hyperactive Member
Re: Get all child objects
 Originally Posted by eSPiYa
Is there a property/function all?
Have you tried all?
Rate Me! Rate Me! Rate Me!
Time to fly.
Copyright GraysonSoft Inc. 2007
-
May 28th, 2007, 12:40 AM
#7
Thread Starter
Fanatic Member
Re: Get all child objects
-
May 28th, 2007, 12:48 AM
#8
Hyperactive Member
Re: Get all child objects
Rate Me! Rate Me! Rate Me!
Time to fly.
Copyright GraysonSoft Inc. 2007
-
May 28th, 2007, 04:48 AM
#9
Re: Get all child objects
It's document.forms and there is no property all. Just iterate over document.forms[n] and you'll get all of the input controls.
Code:
for (c in document.forms['myform'])
c.style.color = 'red';
-
May 28th, 2007, 04:52 AM
#10
Thread Starter
Fanatic Member
Re: Get all child objects
-
May 28th, 2007, 04:54 AM
#11
Re: Get all child objects
-
May 28th, 2007, 04:59 AM
#12
Thread Starter
Fanatic Member
Re: Get all child objects
Ok. Thanks.
That is what I need.
-
May 28th, 2007, 08:04 PM
#13
Hyperactive Member
Re: Get all child objects
 Originally Posted by penagate
It's document.forms and there is no property all. Just iterate over document.forms[n] and you'll get all of the input controls.
Code:
for (c in document.forms['myform'])
c.style.color = 'red';
Yeah. Sorry about that. My javascript as of now sucks.
I alway mix HTML Library object with javascript.
Rate Me! Rate Me! Rate Me!
Time to fly.
Copyright GraysonSoft Inc. 2007
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|