1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Color Picker with "Real Time" Database Connection

Discussion in 'MySQL' started by phaze3131, Mar 13, 2015.

  1. #1
    Hello fellow nerds!

    I am trying to do something a little unique. I want to create a color picker that has all Hex colors stored in a mysql DB.

    Users have the ability to select a color, then having that color "removed" from the DB making it not available to be chosen by another user.

    I want to have the color picker update the user as the user slides around to select a color. Meaning in real time display not only the color the user is hovering over, but also if it is available or not.

    If its available then they can select "choose" and being the process of registering to a site.

    What are some complications I might have in doing this?

    Could the user stay connected to the DB so that a new connection is not made each time they stop on a color?

    What type of delays would I be looking at do you think?

    [​IMG]

    short video:
    http://screencast.com/t/ywp7aZNI5


    Thanks so much for any help!

    Travis
     
    Last edited: Mar 13, 2015
    phaze3131, Mar 13, 2015 IP
  2. Imgup

    Imgup Member

    Messages:
    67
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Well, something like this would be fairly simple to do with PHP and AJAX. You can use (as an example) a JS onmousedown/up to determine if the user is done selecting a colour, once they're done (using onmouseup), fire an AJAX event to query the database and return true or false dependent on the colour being available or not.
     
    Imgup, Mar 13, 2015 IP
  3. freelanceDeveloper

    freelanceDeveloper Member

    Messages:
    59
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    43
    #3
    If you do it onmouseup and ajax, the user would be capable to click many colors resulting in false positives.

    Or after first click you should make the colorpicker unactive.

    A better approach would be to use a colorpicker js that is linked to a form field.
    and the user has to push the submit form button to validate his color... latest approach seems a lot easier and that is how most forms operate.

    something like http://jscolor.com/

    you could add the ajax part as a first check of availability but what I mean is I wouldn't use the ajax part to lock the color. On pageload you can select all remaining colors (or all locked) and disable those on the colorpicker if that functionality is available
     
    Last edited: Jul 31, 2015
    freelanceDeveloper, Jul 31, 2015 IP