Results 1 to 2 of 2

Thread: How to let a user change the background color?

  1. #1
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation How to let a user change the background color?

    Hello, I am trying to set it up on my website that lets users change the color and other styles of certain areas, and then preview those changes in another window. Right now I am just trying to test a little piece of it to see how it works but I'm not having any luck.

    This is my javascript:

    function Avatar() {
    var bgColor1 = document.getElementById("bgColor1")
    var profilePic = document.getElementById("profilePic")

    profilePic.style.bgColor = bgColor1.value
    }

    And this is my html:

    <input type="text" id="bgColor1" maxlength="6" size="8" class="colorpickerField2" onchange="Avatar(this.value" >
    <br />
    <div id="profilePic"></div>

    This text box has a drop down color picker that I implemented so that my user can choose their color, http://www.eyecon.ro/colorpicker/
    (The color picker works but its just that it doesnt change the color of the div) If anyone knows a way that I could get this to work, please tell me!!!

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try:
    Code:
    function Avatar() {
      var bgColor1 = document.getElementById("bgColor1");
      var profilePic = document.getElementById("profilePic");
      profilePic.style.backgroundColor = bgColor1.value
    }
    Jeremy | jfein.net

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
  •