?
Solved

Setting focus on field.

Posted on 2006-04-03
8
Medium Priority
?
243 Views
Last Modified: 2010-04-01
Hi experts,
  I m looking for setting focus on particular field.
How many ways we can do it?
Basically I want to without javascript or may be without using onLoad event?


0
Comment
Question by:Manish
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 11

Author Comment

by:Manish
ID: 16368141
Basically I want  without using javascript or may be without using onLoad event?
0
 
LVL 11

Expert Comment

by:fargo
ID: 16368184
you have to use onload like the following:

<body onload="document.Formname.fieldname.focus();" >
...
..
</body>

There is no other way AFAIK.

fargo
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 16368368
you can try using TABINDEX property of HTML as well..
set it to 1 to get the focus..
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Accepted Solution

by:
TimYates earned 200 total points
ID: 16368480
>> There is no other way AFAIK.

Yes there is...

Put the javascript inline...

ie:

<html>
  <head><title>Woo!?</title></head>
  <body>
    <form>
      <input type="text" name="firstParam"><br>
      <input type="text" name="secondParam" id="focusMe"><br>
    </form>
    <script type="text/javascript">
      document.getElementById( 'focusMe' ).focus() ;
    </script>
  </body>
</html>

Should work too..
0
 
LVL 11

Expert Comment

by:fargo
ID: 16368488
Tim, I mean to say that there is no other way of doing this (except javascript).
I don't know whether tabindex will work!

fargo
0
 
LVL 35

Expert Comment

by:TimYates
ID: 16368495
>> Tim, I mean to say that there is no other way of doing this (except javascript).

Sorry, I thought you meant there was no other way but the onLoad event ;-)
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 16368666
went thru the DHTML reference library...  
object.focus() method is the only way to setting the focus on any element..
0
 
LVL 11

Author Comment

by:Manish
ID: 16368751
Thank you,
  I will get back to u guys.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If anyone asked you to network diagram of the internet, it was drawn in the form of a fluffy cloud which further became known as cloud computing. Popularly cloud computing is defined as workloads that run over the internet in a commercial provider’s…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question