Help here 👇 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Help here 👇

when making a form in html where one has to select the year of birth is there a way to automate the values instead of writing all those values for example from year 1920-2018?

17th Apr 2018, 12:39 PM
Joseph Mbugua
Joseph Mbugua - avatar
8 Answers
+ 5
You could use <input type="date">
17th Apr 2018, 12:45 PM
Zeke Williams
Zeke Williams - avatar
+ 4
Thanks guys, you really saved me and my time Zeke Williams, Xan and Niush sitaula
17th Apr 2018, 1:01 PM
Joseph Mbugua
Joseph Mbugua - avatar
+ 3
Yes. PHP. This is probably the older method. Go with the other suggestions. This code us useful for populating option menus with other data though. https://code.sololearn.com/wqBEj3P5Nq0E/?ref=app function option_menu() { $html = "<select>"; for ($year = 1920; $year <= 2018; $year++) { $html .= '<option id="' . $year . '">' . $year . '</option>'; } $html .= "</select>"; return $html; }
17th Apr 2018, 12:46 PM
Emma
+ 3
Zeke Answer 👍 Also, you can set min and max. <input type="date" min="1970-01-01" max="2050-12-30">
17th Apr 2018, 12:50 PM
Niush
Niush - avatar
+ 2
JoeMbugua Go with the type="date" solution for sure. I don't think that was available when I first learned HTML back in the day! It's a much better solution. Good luck with your project ☺
17th Apr 2018, 1:03 PM
Emma
+ 2
Niush sitaula Apologies for my outdated solution. Back in the day we had to create that all ourselves. I must brush up on the updates! It's great learning off others on here.
17th Apr 2018, 1:19 PM
Emma
+ 1
Xan Yes it was added in HTML5. Date, Time, Color etc picker are really helpful.
17th Apr 2018, 1:06 PM
Niush
Niush - avatar
0
es muy fácil amigo presta atención
17th Apr 2018, 6:01 PM
Brayan Caceres Torres
Brayan Caceres Torres - avatar