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?
8 Answers
+ 5
You could use <input type="date">
+ 4
+ 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;
}
+ 3
Zeke Answer 👍
Also, you can set min and max.
<input type="date" min="1970-01-01" max="2050-12-30">
+ 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 ☺
+ 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.
+ 1
Xan
Yes it was added in HTML5.
Date, Time, Color etc picker are really helpful.
0
es muy fácil amigo presta atención