SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot dhantiflag's Avatar
    Join Date
    Mar 2005
    Location
    Mentor, oh
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    change color of a <div>

    i have a color picker and everything were as of right now i can change the color of a text box and but for some reason when i try and switch it over to the div i cant figure out how to have it change the background

    this is the line that sets the text box color
    color_picker_form_field.style.backgroundColor = this.getAttribute('rgbColor');

    how do i need to setup the style.backgroundcolor section for the div?

    so like

    div1.style.? = this.getattribute('rgbColor')

    thanks in advance

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    div1.style.backgroundColor = this.getAttribute('rgbColor')

  3. #3
    SitePoint Zealot dhantiflag's Avatar
    Join Date
    Mar 2005
    Location
    Mentor, oh
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats what i tried, but it doesn't seem to work

    color_picker_form_field.style.backgroundColor = this.getAttribute('rgbColor');
    that actually = div1
    some reason it wont work

  4. #4
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what error are you getting?

  5. #5
    SitePoint Zealot dhantiflag's Avatar
    Join Date
    Mar 2005
    Location
    Mentor, oh
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i don't recieve an error, it just wont change

    http://whereiskevinholy.com/dev/test.html

    there are 2 divs and 1 text box

    the text box way works, im able to change the background
    but for the Divs when u click them to set the color it wont set it.
    just kinda hangs there

  6. #6
    SitePoint Zealot dhantiflag's Avatar
    Join Date
    Mar 2005
    Location
    Mentor, oh
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i figured it out, on the html i was using document.form[0] where i should be using getElementById

    thanks for all the refs/help :-)


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
  •