Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Foucs on a Text Box using javascript?

Foucs on a Text Box using javascript?

Scheduled Pinned Locked Moved ASP.NET
questionjavascript
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fmlove
    wrote on last edited by
    #1

    Hi! how can i Foucs on a Text Box using javascript?

    P D 2 Replies Last reply
    0
    • F fmlove

      Hi! how can i Foucs on a Text Box using javascript?

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      document.getElementByid("TextBoxID").focus();

      Parwej Ahamad g.parwez@gmail.com

      1 Reply Last reply
      0
      • F fmlove

        Hi! how can i Foucs on a Text Box using javascript?

        D Offline
        D Offline
        daniel__c
        wrote on last edited by
        #3

        We usually do something like this: function LoadFocus(){ document.getElementById('<%= <TextBoxName>.ClientID %>').focus(); document.getElementById('<%= <TextBoxName>.ClientID %>').select(); } window.attachEvent("onload", LoadFocus); } This will work for IE, but not sure about attachEvent for ff...would have to check if required.

        M 1 Reply Last reply
        0
        • D daniel__c

          We usually do something like this: function LoadFocus(){ document.getElementById('<%= <TextBoxName>.ClientID %>').focus(); document.getElementById('<%= <TextBoxName>.ClientID %>').select(); } window.attachEvent("onload", LoadFocus); } This will work for IE, but not sure about attachEvent for ff...would have to check if required.

          M Offline
          M Offline
          Michael Sync
          wrote on last edited by
          #4

          daniel__c wrote:

          document.getElementById('<%= .ClientID %>').select();

          Why do we need to do that?

          Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

          D 1 Reply Last reply
          0
          • M Michael Sync

            daniel__c wrote:

            document.getElementById('<%= .ClientID %>').select();

            Why do we need to do that?

            Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

            D Offline
            D Offline
            daniel__c
            wrote on last edited by
            #5

            Sorry, that should be document.getElementById('<%= .ClientID %>') not document.getElementById('<%= .ClientID %>') as originally posted. We usually do the .select() to select any text that is currently in the text box. You can do the focus alone, but the select tends to be a bit more user friendly.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups