focus on a form element after enabling a disabled one

J

jceddy

Hey, I'm running into something that might strike as a bit odd. I have
a function that is, onchange of a form element, disabling a given form
element and then later re-enabling it...basically this is for some
control while asynchronous processes are happening.

Anyway, I've created the following simple code that I've been playing
around with:

-------
<html>
<head>
<title>Test</title>
<script Language="JavaScript">
function doFocusThing() {
document.the_form.the_select.disabled = true;
document.the_form.the_select.disabled = false;

setTimeout( 'bringFocus();', 1000 );
}

function bringFocus() {
document.the_form.the_text.focus();
//document.the_form.the_select.focus();
}
</script>
</head>
<body>

<form name="the_form">
<select name="the_select" onChange="doFocusThing();">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
<input type="text" name="the_text" />
</form>

</body>
</html>
-------

If you run this in IE, and then select something from the select list,
you'll see the select lost focus (because it was disabled, presumably),
but the text field never gets focus afterward.

Anyone got a good reason why not and maybe even an idea of what I could
do in this case to get focus on this thingie?

Cheers,
Joe
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top