Adding jQuery datepicker for more than one text box in asp.net mvc 3 -


i working on asp.net mvc 3 application. in 1 of partial views render fields should provide option select date. use jquery datepicker plugin , sample code found on net :

if (field[i].mcs_fields.fieldtypeid == 2)                     {                          <script type="text/javascript">                             $(function () {                                 $(".datepicker").datepicker();                             });                         </script>                         @field[i].questiontext;                         @html.textbox("datepicker", "", new { @class = "datepicker" })                     } 

the problem if more 1 @html.textbox no matter pick date change made on first textbox class="datepicker". have no experience js, jquery , on, suggest way allow me add n number of @html.textbox , being able pick date each 1 separately?

put on page bottom,it render datepickers:

$(".datepicker").each(function() {     $(this).datepicker(); }); 

edit: if doesn't work guess may put in wrong place code run before html rendered,try this

$(document).ready(function(){     $(".datepicker").each(function() {         $(this).datepicker();     }); }); 

see jsfiddle


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -