-1

I need to create a filter form which only shows year option. The input can be be a dropdown list of year or datepicker that only shows year option.

Do you know how to create it? please let me know, I am a beginner, I have tried to find solution, but didn't find any.

Thank you, I appreciate any helps.

Andri Setiawan
  • 49
  • 1
  • 10

2 Answers2

1

Thanks @Reystleen for answer in the comment!

ANSWER: https://itsolutionstuff.com/post/bootstrap-year-picker-example-using-datepicker-jsexample.html

CODE:

<html lang="en">
<head>


    <title>Bootstrap - year picker only example</title>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>


</head>
<body>


<div class="container text-center">


     <h2>Bootstrap - year picker only example</h2>
     <input class="date-own form-control" style="width: 300px;" type="text">


  <script type="text/javascript">
      $('.date-own').datepicker({
         minViewMode: 2,
         format: 'yyyy'
       });
  </script>


</div>


</body>
</html>
Andri Setiawan
  • 49
  • 1
  • 10
0

Something like this:

<select name="birthyear">
    <option value="2018">2018</option>
    <option value="2017">2017</option>
    <option value="2016">2016</option>
    <option value="2015">2015</option>
    <option value="2014">2014</option>
    <option value="2013">2013</option>
    <option value="2012">2012</option>
    <option value="2011">2011</option>
    <option value="2010">2010</option>
etc.
   </select>
Reystleen
  • 68
  • 1
  • 7
  • I need something like datepicker. Because the year will be a lot like 1997-2018 and it is potentially more coming additional year. But, thank you anyway for help – Andri Setiawan Jan 17 '18 at 11:03
  • I found this: https://stackoverflow.com/questions/13528623/jquery-ui-datepicker-to-show-year-only and if you are ok to use Bootstrap: https://itsolutionstuff.com/post/bootstrap-year-picker-example-using-datepicker-jsexample.html – Reystleen Jan 17 '18 at 12:48
  • Cool! this is what I need. THANKSS :) https://itsolutionstuff.com/post/bootstrap-year-picker-example-using-datepicker-jsexample.html @Reystleen – Andri Setiawan Jan 18 '18 at 02:41