javascript for change in color when clicked in text box?

Discussion in 'PHP' started by hulkrana, May 26, 2007.

  1. #1
    helo frds

    i want change in colour of textbox background colour throuigh javascript.
    please tel me this answewr?
    thanks
     
    hulkrana, May 26, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
  3. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #3
    it's rather simple really. create two css classes and change them on the onfocus and onblur events.

    example:

    css:
    
    .normal
    {
        background-color:gray;
    }
    
    .focus
    {
        background-color:white;
    }
    
    Code (markup):
    and then as for the javascript part...

    
    <input type="text" size="40" class="normal" onfocus="this.className='focus'" onblur="this.className='normal'" />
    
    Code (markup):
     
    ansi, May 26, 2007 IP
  4. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Isn't this the PHP forum?
     
    manilodisan, May 26, 2007 IP
  5. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #5
    that it would be.
     
    ansi, May 27, 2007 IP
  6. Nerve

    Nerve Peon

    Messages:
    467
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yea, this was posted in the wrong forum.
     
    Nerve, May 27, 2007 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    [​IMG]
     
    nico_swd, May 27, 2007 IP