Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post

    Highlighting text box contents on click

    How can you get the contents of a text box to automatically highlight when the user clicks anywhere in the text box?

    Thanks much!

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    </
    head>

    <
    body>
    <
    input name="" size="10" value="fred"
    onfocus="javascript:this.style.backgroundColor='#336699';"
    onblur="javascript:this.style.backgroundColor='white';"
    >
    </
    body>

    </
    html

  • #3
    New Coder
    Join Date
    Aug 2004
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Hi,

    Are you looking for this?

    Code:
    <input type="text" value="Click on me" onclick="this.select()">
    This is to select contents of textbox. If you just want to change color, then you can use vwphilips code. Its a nice one.

    Afru.

  • #4
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    Oh yes.. I meant to select the contents.

    Thanks guys!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •