Recursively Find a Control?

Discussion in 'Javascript' started by bradwiseathome@hotmail.com, Mar 17, 2005.

  1. Guest

    I have some web-server-side code that may place a textbox anywhere on a
    page. It might be on the page itself, it might be within a <form>, it
    might be within a <div> in the form, or in a <div> inside the first
    <div>.

    Is there a script out there that will let me, given just the control's
    ID, recursively find it anywhere on the page so I can set focus to it?

    Any pointers appreciated - this is making me nuts!

    Thanks.
     
    , Mar 17, 2005
    #1
    1. Advertisements

  2. RobB Guest

    wrote:
    > I have some web-server-side code that may place a textbox anywhere on

    a
    > page. It might be on the page itself, it might be within a <form>, it
    > might be within a <div> in the form, or in a <div> inside the first
    > <div>.
    >
    > Is there a script out there that will let me, given just the

    control's
    > ID, recursively find it anywhere on the page so I can set focus to

    it?
    >
    > Any pointers appreciated - this is making me nuts!
    >
    > Thanks.


    They made DOM a little easier than that...

    var el = null;
    if (document.getElementById)
    el = document.getElementById('box_id');
    else if (document.all)
    el = document.all['box_id'];
    if (el && el.focus)
    el.focus();

    Make sure to wait till the page is fully loaded.
     
    RobB, Mar 17, 2005
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    9
    Views:
    5,325
  2. Mike James
    Replies:
    1
    Views:
    1,929
    Jim Gibson
    Sep 19, 2003
  3. Lanny McDonald
    Replies:
    1
    Views:
    417
    Alvin Bruney [MVP]
    Apr 3, 2004
  4. =?Utf-8?B?RGFuIE5hc2g=?=

    adding subnodes to a tree recursively

    =?Utf-8?B?RGFuIE5hc2g=?=, Oct 16, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    860
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Oct 18, 2004
  5. Wybo Dekker
    Replies:
    1
    Views:
    604
    Yukihiro Matsumoto
    Nov 15, 2005
  6. Replies:
    17
    Views:
    1,636
    Eric J. Roode
    Nov 12, 2005
  7. vdvorkin
    Replies:
    0
    Views:
    589
    vdvorkin
    Feb 10, 2011
  8. vdvorkin
    Replies:
    3
    Views:
    1,062
    vdvorkin
    Feb 14, 2011
Loading...