Sammy
Sammy

Reputation: 777

Simple JavaScript datepicker bug?

I'm using jQuery datepicker, and I'm using this code ...

<script>
    $(function() {
      $("#datepicker").datepicker();
      //$("#datepicker2").datepicker();
    });
</script>

...at the header of my page. Meanwhile, with PHP, I want to call it an indefinite number of times.

But I can't use this function to place "datepicker" more that once if there is only one: $("#datepicker").datepicker(); on the function.

How can I call this function an indefinite number of times?

Upvotes: 3

Views: 217

Answers (2)

Maen
Maen

Reputation: 10698

IDs are meant to be unique.

Switch your #datepicker for .datepicker on your html and on your jQuery.

Upvotes: 1

bipen
bipen

Reputation: 36531

call a class ..

$(".datepicker").datepicker();

and you can call indefinite number of time ..just that all your input should have the class datepicker

example

<input name="test1" class="datepicker" />
<input name="test2" class="datepicker" />
.......

Upvotes: 3

Related Questions