SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamically change bgcolor of text inputs

    Good Morning,
    Can I use Javascript, etc. to apply css formatting to forms fields dynamically? I want to change the background color of some text boxes to grey when they are disabled, and white when they are enabled. Enabled/disabled property is triggered by an onclick event elsewhere on the page.

    Thank You,
    David

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function enable(elem){
       elem.disabled = false;
       elem.style.backgroundColor = '#FFFFFF';
       elem.style.color = '#000000';
    }
    function disable(elem){
       elem.disabled = true;
       elem.style.backgroundColor = '#CCCCCC';
       elem.style.color = '#333333';
    }
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, worked great.


Bookmarks

Posting Permissions

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