How do I get this in a loop?

How do I get this in a loop?

I'm trying to get a datepicker function repeated in a loop.
 
The functions below work fine as shown, with the i variable referring to a location in ProductArray[], which contains ids of divs.  Let's say the array has 3 items:
 
var i = 1;

$(function() { 
    $(ProductArray[i]).datepicker({
        maxDate: etc. etc. ,
    }); 
});     





$(function() { 
    $(ProductArray[i+1]).datepicker({
        maxDate: etc. etc.
    }); 
});     



 
$(function() { 
    $(ProductArray[i+2]).datepicker({
        maxDate: etc. etc.
    }); 
});



 
As said, this works fine. But surely it can be done a lot shorter with a loop.
 
I tried a javascript for loop and a while loop, but then all of a sudden the datepicker won't show up anymore.
 
Any ideas, perhaps how to do it with  the .each function?  I have no clue how to rewrite it using .each.
 
Thanks for any help!