onclick and changing bg color of a input box?

Discussion in 'JavaScript' started by grobar, Jul 20, 2006.

  1. #1
    how is this done?

    i cant get it to work./

    i have:

    <input class="inputbox" type="text" size=19 name="Name" onClick="form.bgColor = '#282484';">
     
    grobar, Jul 20, 2006 IP
  2. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <input class="inputbox" type="text" size=19 name="Name" onClick="this.style.backgroundColor = '#282484';">
    Code (markup):
    Should work if I remember correctly, I'll test it in a second....

    ...Yeah works great.
     
    giraph, Jul 20, 2006 IP
  3. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I'd use onfocus() instead of onclick() so that it'll also work when the input gets focus from user typing the TAB, for example.
     
    phper, Jul 20, 2006 IP