SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  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
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,075
    Mentioned
    219 Post(s)
    Tagged
    12 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?

  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
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,075
    Mentioned
    219 Post(s)
    Tagged
    12 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.


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
  •