I've got some code that uses the regular Forms API to put together a simple form. I'm using the jQuery Tools package to generate this form and insert it into an overlay. This is working fine, but I'd like to have the input focus set to a text field in the form once it's exposed. I've tried tacking some jQuery code that should do it --
<script type='text/javascript'>$('#textfieldID').focus();</script>
-- or somesuch onto the end of the form in the form's theming function, but it's not getting loaded onto the page. I'm guessing this is because some part of Drupal is being "helpful" and filtering out the script, but I'm not really certain. In any case, the code's not getting run -- if I insert a javascript alert() statement as part of the code, nothing happens.
Any advice out there? I'd really like to get the focus set on this guy. Thanks!
I'm declaring this to be "answered" -- after digging deeper (= blood on the keyboard), it's now clear to me that jQuery Tools is the culprit here -- the form, as created by Drupal, definitely contains whatever scripting stuff I insert into it (latest scheme: a $(document).ready(...focus...) as a markup element in the form). Somewhere in making its way through the jQT overlay process, the scripting goes away. The main hint: If I disable the overlay such that the form comes up in a regular page, the script is present, runs, and correctly sets the focus.
Blurg; at least I (think I) know what's going on -- even though it's not working, I've got a better question to ask. Thanks to all for the help along the way.