Results 1 to 13 of 13

Thread: [RESOLVED] Get all child objects

  1. #1

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Resolved [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?

  2. #2
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: Get all child objects

    Quote 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

  3. #3

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: Get all child objects

    Maybe it is a good alternative.
    How about getting child elements regardless of tag?

  4. #4
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: Get all child objects

    Quote 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

  5. #5

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: Get all child objects

    Is there a property/function all?

  6. #6
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: Get all child objects

    Quote 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

  7. #7

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: Get all child objects

    Nope.

  8. #8
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: Get all child objects

    Can you try all?
    Rate Me! Rate Me! Rate Me!

    Time to fly.

    Copyright GraysonSoft Inc. 2007

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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';

  10. #10

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: Get all child objects

    What is c?

  11. #11
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

  12. #12

    Thread Starter
    Fanatic Member eSPiYa's Avatar
    Join Date
    Jun 2006
    Location
    in our house
    Posts
    751

    Re: Get all child objects

    Ok. Thanks.
    That is what I need.

  13. #13
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: Get all child objects

    Quote 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
  •  



Click Here to Expand Forum to Full Width