How to use datepicker with dynamic table

Posted on 2013-01-29
Medium Priority
Last Modified: 2013-01-29
I am trying to use jQuery datepicker with a dynamic table. The problem I am having is that the date picker keep changing the date in the first row. The codes I am currently using is as follows:-

$( document ).ready(function() {


            $(".datepicker").datepicker({dateFormat: "dd M yy", changeMonth: true, changeYear: true,Anim:"Clip"});

            $(".datepicker").attr('readOnly', 'true');


    $(".button").click(function() {

                var $currentrow= $(this).closest('tr');
                var $newrow=$currentrow.clone(true);
                $newrow.find(".datepicker").datepicker({dateFormat: "dd M yy", changeMonth: true, changeYear: true,Anim:"Clip"});




Open in new window

So what do I need to do to insert the date into the new row.

Question by:Sheils
LVL 83

Accepted Solution

leakim971 earned 2000 total points
ID: 38830800
Test page : http://jsfiddle.net/F5cPx/
$( document ).ready(function() {
    $(".datepicker").datepicker({dateFormat: "dd M yy", changeMonth: true, changeYear: true,Anim:"Clip"});
    $("table").on("click", ".button", function() {
        var $newrow = $(this).closest('tr').clone().appendTo('table');
        var id = "dp"+new Date().getTime();
        $("#" + id).datepicker({dateFormat: "dd M yy", changeMonth: true, changeYear: true,Anim:"Clip"});

Open in new window

LVL 16

Author Closing Comment

ID: 38834190
Thanks Mate

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question