I’m using a datePicker that can be found here:
http://www.frequency-decoder.com/2011/10/11/unobtrusive-accessible-datepicker-widgit-v6
I have it working fine, as long as I hard code the id of the object. i.e.
var newid = "date" + maxidOnce.toString();
datePickerController.createDatePicker({
formElements:{"date1":"%Y-%m-%d"},
statusFormat:"%l, %d %F %Y",
noFadeEffect:true
});
However if I replace the id with the variable, it no longer works. I don’t see how there is any difference.
var newid = "oncedate" + maxidOnce.toString();
datePickerController.createDatePicker({
formElements:{newid:"%Y-%m-%d"},
statusFormat:"%l, %d %F %Y",
noFadeEffect:true
});
The difference is that JavaScript object keys are not interpreted as variables when using object literals. Use bracket notation instead.