Jquery ui datepicker php array s - JQuery UI’s datepicker and HTML Arrays?

2nd of January 2011 0

JQuery UI’s datepicker and HTML Arrays?

I have PHP creating a dynamic list of fields, which I would like to use JQuery UI’s datepicker on. All of the fields are in an array so I can manage them easy…so how can I make it make all of the fields use the datepicker? I’ve tried the following with no luck:

// Datepicker
$ (‘#datepicker[]’).datepicker({
inline: true,
showButtonPanel: true,
changeMonth: true,
changeYear: true
});
I’ve tried hard coding one as well and it doesn’t work:

$ (‘#datepicker[1]‘).datepicker({
inline: true,
showButtonPanel: true,
changeMonth: true,
changeYear: true
});

Best answer:

Answer by Chris B
This answer is a guess:
// Datepicker
$ (‘#datepicker[*]‘).datepicker({ // Added asterick (*) for wild card?
inline: true,
showButtonPanel: true,
changeMonth: true,
changeYear: true
});

Anyways, If i understand you correctly, why do you not use a for loop?:
for(var i = 0, i < count(datepicker), i++){ $ ('#datepicker[i]').datepicker({ inline: true, showButtonPanel: true, changeMonth: true, changeYear: true }); } instead of count, research what the JavaScript syntax for finding an array's length is. I used C++'s method, not sure if they are the same or not. Good Luck!

Know better? Leave your own answer in the comments!

Share it!

Was it good for you to?

Sponsors

Support for the site!

No sponsors at the moment.



Your opinion matters. Add it below.


Tip: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent comments

Categories



Copyright jqueryui.info since 2010. All rights reserved. Design and the Absolute Theme by Tommie Hansen.