Auto Textbox focus

Ask a question about a MLMF feature, or request support.

Auto Textbox focus

Postby Highway of Life on Fri Feb 17, 2006 6:09 pm

Place the following code in the <head> section.
Code: Select all
<script language="javascript" type="text/javascript">
   function placeFocus&#40;&#41;
      &#123;
      if &#40;document.forms.length > 0&#41;
         &#123;
         var field = document.forms&#91;0&#93;;
         for &#40;i = 0; i < field.length; i++&#41;
            &#123;
         if &#40;&#40;field.elements&#91;i&#93;.type == "text"&#41; || &#40;field.elements&#91;i&#93;.type == "textarea"&#41; || &#40;field.elements&#91;i&#93;.type.toString&#40;&#41;.charAt&#40;0&#41; == "s"&#41;&#41;
               &#123;
               document.forms&#91;0&#93;.elements&#91;i&#93;.focus&#40;&#41;;
               break;
               &#125;
            &#125;
         &#125;
      &#125;

   // End hiding script from old browsers -->
   </script>

Code: Select all
<body onload="placeFocus&#40;&#41;;">
phpBB3 MOD Developer, Olympus Wiki Author

I'm not here much, as most of my time is spent developing software on StarTrekGuide. Please post on STG if you require immediate assistance.
Image
User avatar
Highway of Life
Junior Lieutenant
Junior Lieutenant
 
Posts: 217
Joined: Tue Aug 17, 2004 10:24 pm
Location: In the middle of the Road

Postby Handyman on Mon Feb 20, 2006 2:48 am

There actually appears to be a built in javascript for it, so all I had to do was place a focus in the body tag and it works now.
User avatar
Handyman
Ambassador|Command Ambassador
Ambassador|Command Ambassador
 
Posts: 663
Joined: Tue Aug 17, 2004 7:37 pm


Return to MLMF Support / Questions

Who is online

Users browsing this forum: No registered users and 3 guests

cron