如何使用jquery仅将年份绑定到下拉列表

时间:2014-12-13 11:51:03

标签: jquery

我是jquery的新手,我需要使用jquery绑定到dropdownlist只有几年。但是它没有绑定到dropdownlist。有人建议我......

在jquery中

  function addYear() {
        var currentYear = new Date().getFullYear();

        for (var i = 1; i <= 5; i++) {
            $("#PassedYear").append( $("<option></option>")
                    .attr("value", currentYear)
                    .text(currentYear)


            );
            currentYear++;

        }
    }

    addYear();

在视图中

         

         <td>
             Certification Name
         </td>
         <td>
             Passed Year
         </td>
     </tr>

@for (var j =0; j < Model.EducationDetailsFields.Certifications.Count; j++)

{


     <tr>

                    <td>
                        <div id="Certified" class="disable">
                            @Html.TextBoxFor(model => model.EducationDetailsFields.Certifications[j].CertificationName)
                            @Html.ValidationMessageFor(model => model.EducationDetailsFields.Certifications[j].CertificationName)
                        </div>
                    </td>

                     <td>
                        <div  class="disable">
                          @Html.DropDownListFor(model => model.EducationDetailsFields.Certifications[j].PassedYear, new SelectList(Model.EducationDetailsFields.Certifications, "Passedyear", "Passedyear"), "--Select--", new {id="PassedYear" })


                            @Html.ValidationMessageFor(model => model.EducationDetailsFields.Certifications[j].PassedYear)
                        </div>
                    </td>
                </tr>



}



      </table>

在页面加载3下拉列表应该加载多年...这里第一个下拉列表被加载,休息不是..如何添加循环变量j到下拉列表ID。可以任何一个请看看它

0 个答案:

没有答案