[pmwiki-users] can the cursor be positioned on forms?

ljb ljb220 at mindspring.com
Thu Mar 23 18:32:32 CST 2006


pmichaud at pobox.com wrote:
>...
> I might see if I can find a generic javascript snippet that will
> always focus the first field in the form (instead of an explicitly
> named field as it does now).

Maybe this:
   document.forms[0].elements[0].focus();

Unless there might be hidden form fields at the top of the form. If so,
maybe this:
  for (i=0; i<document.forms[0].elements.length; i++)
    if (document.forms[0].elements[i].type != 'hidden') {
      document.forms[0].elements[i].focus();
      break;
    }

All this assumes there is only one form on the page. (Not true with my
site's skin, which has a search form in the header.)





More information about the pmwiki-users mailing list