I use the JQuery datepicker, and the problem is that I generate the HTML, so I don’t know in advance the ID’s of the fields.
My code can be tried at http://jsfiddle.net/littlesandra88/KrEqk/
The forms below are generated, where the ID’s just get prefixed with a random number to make them different.
What I did to get datepicker in those fields was to add class="datepick" to those fields like so
<input name="from" id="114_begin_date" value="16/05-2011" type="text" class="datepick" />
<input name="to" id="114_end_date" value="16/05-2011" type="text" class="datepick" />
and add .datepick to the inline datepicker JavaScript, like so
var dates = $("#from, #to, .datepick").datepicker({
If you try to change the dates several times you will notice, that all fields are updated =(
How do I prevent that from happening, so just the field that I click on is changed?
The problem is in the
onSelecthandlerYou are running
this changes all the other datepickers to a single value (the one of the current datepicker)..
Update for comment
change your
onSelectmethod tochanges made
var self = this;for later usenameattribute instead of theidto decide which limit to usefromandto)demo at http://jsfiddle.net/gaby/Wy6qT/