SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: help with color picker

  1. #1
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with color picker

    I have a javascript as:

    <label>Bakgrunn/label>
    <button onClick="javascript:changeBGC('blue')">Blå</button>
    <button onClick="javascript:changeBGC('white')">Hvit</button>
    <button onClick="javascript:changeBGC('black')">Svart</button>
    <label>Skrift/label>
    <button onclick="javascript:changeTextColor('black')">Svart</button>
    <button onclick="javascript:changeTextColor('white')">Hvit</button>
    <button onclick="javascript:changeTextColor('yellow')">Gul</button>

    I'm a newbie to both javascript and jquery, but I'd like to solve this color selecting by a color picker like the spectrum color picker: http://bgrins.github.com/spectrum/

    Can anyone help with this one?

  2. #2
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,482
    Mentioned
    40 Post(s)
    Tagged
    2 Thread(s)
    Hi pmonstad,

    Welcome to the forums!

    I'm not too sure what you're trying to accomplish here.
    Could you go into a little more detail?

    From what you posted, it seems like you have several buttons which change the background and text colour when you press one.
    You don't really need a colour picker for that.

    Here is an example of a simple style changer I made for someone else.
    Does that help you any?
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

  3. #3
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I guess this could help me. A question about your script. I see it includes some cookies. I have not gone deep into understanding your code, but what do the cookies do?

  4. #4
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,482
    Mentioned
    40 Post(s)
    Tagged
    2 Thread(s)
    These ensure that the style changes persist between pages (a style switcher wouldn't be much use if you had to reselect your styles every time you moved from one page to the next ).
    If you are interested I wrote all of this up as a blog post.
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

Tags for this Thread

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
  •