Garima Bansal

Garima Bansal

  • 1k
  • 694
  • 41.4k

bind dropdown in form

Feb 10 2023 6:05 AM

i tired to bind year dropdown like this

<div class="col-sm-7">
                                <select id="dropdown">
                                    <option value="">-Select-</option>
                                </select>
                            </div>

 let dateDropdown = document.getElementById('dropdown');

        let currentYear = new Date().getFullYear();
        let earliestYear = 1970;

        while (currentYear >= earliestYear) {
            let dateOption = document.createElement('option');
            dateOption.text = currentYear;
            dateOption.value = currentYear;
            dateDropdown.add(dateOption);
            currentYear -= 1;
        }

and its shows dropdown of year,

but my problem is how can i bind or fetch in backend code

 revivalForm.Year = ??


Answers (4)