Color swatches is not proper working in Dawn 15.0

Actually, I am implementing this code, but the problem is that whenever I try to select a color, it always defaults to the first color. Even if I try to select the second or third color, it still selects the first one. @tim_1