Recursively Find a Control?

B

bradwiseathome

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.
 
R

RobB

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top