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 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    61
    Thanks
    8
    Thanked 0 Times in 0 Posts

    input field color help

    Hi, i found a website that there input field is colored & brightens once u click on the field. How do i do that? Here's my input field code

    Code:
    <input name="name" value="Server Name" /><br><input name="ip" value="Server IP" /><br><input name="port" value="Server Port" />

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,089
    Thanks
    23
    Thanked 593 Times in 592 Posts
    First added css to get a back ground color. Then added an ID so the back ground color knows what to color. Then added onfocus, it could have been an onclick, to change the color via a javascript command. I only added it to the first input.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <style type="text/css">
    #name, #ip, #port{
    	background-color: SlateGray;
    }
    </style>
    </head>
    <body>
    <input id="name" onfocus="this.style.backgroundColor='silver';" name="name" value="Server Name" /><br />
    <input id="ip" name="ip" value="Server IP" /><br />
    <input id="port" name="port" value="Server Port" />
    </body>
    </html>


  •  

    Posting Permissions

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