How to get values from inputs

How to get values from inputs

Hi there, I want to create a dynamic clickable color picker like this:


When I click a square it has to select a color from the list - it's simple but...

There are inputs with the same name="color_number" - I'm trying to get those values but it returns just the first one, so there's working just first color.

This is my code:

  1. var color_number = $j('[name=color_number]').val();

            $j('div.color-picker-'+color_number).click(function() {
                $j("#input_Kolor option:contains('"+color_number+"')").val();
                $j("#input_Kolor option[selected]").removeAttr("selected");
                $j("#input_Kolor option:contains('"+color_number+"')").attr("selected", "selected");
            }); 





I can define every color by myself but there is a lot of colours and I want to make it dynamic.

Cheers!