[jQuery] javascript sending variables to the datepicker

[jQuery] javascript sending variables to the datepicker


Purpose of the script- the script should count the rows of a table
with id name. Then create a datepicker function with each unique id.
In this example , Date0, Date1,Date2,Date3
<script type="text/javascript">
function numrows()
{
    var date="Date";
    var rowCount = document.getElementById("test").getElementsByTagName
("tr").length;
    rowCount=rowCount-1;// the number of rows minus the table header
<th></th>
    alert(rowCount);
    for (var i=0; i<=rowCount; i++)
    {
        date=date +i;
        alert(date);// this will displays the id's i want the datepicker to
have
        $(function()
        {
        $(date).datepicker();<<<<<<<<this is the problem here
        }
    );
    date="Date";//resets the date but not the counter i
    }
}
</script>
PS:Just in case I will explain myself one more time. This is an
example of a manual way to achieve what I want. However, I do not want
to input each element by hand. I want javascript to count the number
of rows and create the elements as shown above.
Basically what I want is this ,but I want the script to be able to
detect how many elements it should create
    <script type="text/javascript">
    $(function() {
        $("#Date0").datepicker();//element 1
$("#Date1").datepicker();//element 2
$("#Date2").datepicker();//element 3
$("#Date3").datepicker();/. element 4
    });
    </script>
I hope I am making myself clear.