Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!