Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:57
How do I set input focus in an HTML menu?
Poster: Speednet
Dated: Wednesday January 19 2005 - 16:21:51 GMT
I have a menu with type=html, and that menu has one input space. When the menu opens, I would like to set the input focus to that input space, so that the user already has the cursor blinking in it without having to click it.
I cannot find an "openfunction" property that would fire when the menu first opens (like the "load" attribute on the <body> tag). If there were such a property, I presumably could set that property to "document.form.textelement.focus()".
Anyone have a clue how to do this?
Thanks!
Poster: Andy
Dated: Wednesday January 19 2005 - 23:57:07 GMT
You could do it with a timed function, something like this:
function setFocus()
{
setTimeout("document.forms.search.q.focus()",100);
}
Assuming a form object named "search" and a text box called "q"
Called from the parent menu item with an onfunction embedded inside the aI string, like this:
aI("url=/search.php;text=Search;showmenu=mm search;onfunction=setFocus()");
Hope this helps
Andy
Poster: Speednet
Dated: Thursday January 20 2005 - 0:30:04 GMT
Interesting concept, thanks. It's actually a popup menu, so there's no parent. But I guess I could call the Timeout function just before calling popup(), right?
Poster: Speednet
Dated: Thursday January 20 2005 - 1:00:21 GMT
I just tested it - works great with a popup. I put the following code in the onClick event:
onClick="setTimeout('document.forms.frm.q.focus()',100);popup('menuname');"
Thanks again!
Poster: rudy
Dated: Thursday January 20 2005 - 1:23:11 GMT
I'm interested in doing somethiing like that - mind sharing a URL so we can see it in action
Speednet wrote:
I just tested it - works great with a popup. I put the following code in the onClick event:
onClick="setTimeout('document.forms.frm.q.focus()',100);popup('menuname');"
Thanks again!
onClick="setTimeout('document.forms.frm.q.focus()',100);popup('menuname');"
Thanks again!