Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
input type='color' fields saving as an array in database but not populating input type ='color' 'value attribute'

input type='color' fields saving as an array in database but not populating input type ='color' 'value attribute'

I am trying this but not working.

label(for='firstColor') Color 1
input#firstColor(type='color' name='colors' value = colors)
label(for='secondColor') Color 2
input#secondColor(type='color' name='colors' value = colors)
label(for='thirdColor') Color 3
input#thirdColor(type='color' name='colors' value = colors)

I am receiving this data from database:

{colors: Array(3)
  0: "#f50000"
  1: "#000000"
  2: "#000000"
 }

And using this code to populate:

 $.each(results, function (i,v){
        form.find('[name="'+i+'"]').val(v);
    })

but no success in populating input color value.

PS: multiple checkboxes, multiple select options working fine using same setup above.

Finally solved it by updating code:

 var form = $('#registerForm');
    $.each(results, function (i,v){
        if(i == 'colors'){
        $.each(results.colors, function (a,b){
            $('[name="colors['+a+']"]').val(b);
           
        })
        }else{
        form.find('[name="'+i+'"]').val(v);
    }
    })

I still want to know how it was working without updating code on multiple checkbox and multiple select but not on multiple color inputs?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

If its for a HTML Page, storing the #RRGGBB tag as a string is probably enough.

If its for .NET , it supports building a color from its ARGB Value

System.Drawing.Color c = System.Drawing.Color.FromArgb(int);

int x = c.ToArgb();

so you could just store that int.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda