Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda