views:

18

answers:

1

Jquery UI Function:

// Datepicker
$('#datepicker').datepicker({
inline: true
});

Event:

<input name="txtLogistics_ExecutionDate" type="text" id="datepicker" onfocus="datepicker();" />

My question is:

have confusion on how to implement datepicker across multiple text fields.

Do I have to named each text field ID on the function? How can I assign to any field or pass the ID to Jquery?

+3  A: 

You can use a class, for example:

$('.datepicker').datepicker({
  inline: true
});

With elements like this:

<input class="datepicker" name="txtLogistics_ExecutionDate" type="text" />
<input class="datepicker" name="txtLogistics_OtherDate" type="text" />
<input class="datepicker" name="txtLogistics_YetAnotherDate" type="text" />

This will apply the .datepicker() widget to each element with that class.

Nick Craver
So I don't need the events?
Codex73
@Codex73 - Nope :) just run it on `document.ready`, e.g.: `$(function() { $('.datepicker').datepicker({ inline: true }); });` and it'll execute against all elements once they're in the DOM/ready to go.
Nick Craver