Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 181345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:44:50+00:00 2026-05-11T14:44:50+00:00

I have an AJAX chat system that I’m working on and so far I

  • 0

I have an AJAX chat system that I’m working on and so far I have it working. One thing I want to do is have it so when the user name is displayed on screen, it is a unique color (like in an AIM window). How would I generate a random color to assign to the user’s name for the particular session they are logged in for?

The color would have to be something that is darker as it on white background and as they are generated, they can’t be too similar to the colors that other current users have been assigned.

EDIT Thanks, I guess a predefined list would be the easiest way. If I have this list in a config file and I assign a color when the user logs in, how should I go about making sure that no two logged in users have the same color?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:44:50+00:00Added an answer on May 11, 2026 at 2:44 pm

    I think you’re going to be better off randomly picking from a list of pregenerated colors that meet your requirements (dark enough, different enough from each other) than trying to generate colors on the fly.

    Edited to add:

    As far as keeping more than one user from having the same color, one thing I’ve seen systems do is to just assign colors locally on the users machine using Javascript. Usually it’s not that important that different users see the same colors for other people. I don’t care if the colors on my screen are the same as they are on some other user’s screen, as long as all the colors on my screen are unique. In fact it may be desirable for each user’s own text to be distinct (their’s is black, everyone else’s is colored, for instance).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on an ajax/php chat system where users can obviously chat
I have created a chat system using php and ajax. When a user logs
I have been working on on an AJAX chat application using php, mysql. It's
I have an Ajax request that can return more than one valid value, so
i am trying to making php ajax based chat system....and i have developed it
My question is an elaboration of this one: PHP/MYSQL AJAX Chat I have a
Duplicate Scrolling Overflowed DIVs with JavaScript I have an AJAX chat that outputs the
I am currently developing an IRCX AJAX Chat based system and have a few
I have made a simple chat application in PHP/Ajax/MySQL. I am regularly calling these
I have ajax request that do 3 missions: Save Model (DB) Send Email Give

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.