Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6345621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:51:27+00:00 2026-05-24T20:51:27+00:00

I am trying to figure out why my dynamically added input block (within the

  • 0

I am trying to figure out why my dynamically added input block (within the cell of a table) does not fire the datetime picker. I’ve provided a proof of concept block of code that demonstrates this issue. If you run this code as is, the default input tag (id: dti1) works perfectly and the datetime picker pops up and allows the user to select a date and time. However, when you click “Add Another”, the datetime picker does not pop up on the new input element, even though it shows up properly with the dtpick class properly associated with it. My assumption is that the datetime picker is associated with each dtpick class element on page load, so that’s why the datetime picker isn’t working. Is there any way to force that to happen when I dynamically add the row?

<html>
<head>
<!-- includes: jquery, jquery_ui_datepicker, timepicker-- references removed here-->
<script>
  $(document).ready(function(){
   $('.dtpick').datetime({
     userLang   : 'en',
     americanMode: true});
   });
   function addItem() 
   {
    var t = document.getElementById('myTable');
        var row = t.insertRow(-1);
        var c1 = row.insertCell(0);

        var c1content=document.createElement("input");
        c1content.setAttribute("type","text");
        c1content.setAttribute("name","dtnew");
        c1content.setAttribute("id","dtinew");  
        c1content.setAttribute("class","dtpick");
        c1content.setAttribute("value","2011-08-20 01:00:00");

        c1.appendChild(c1content);  
   }
</script>
</head>
<body>
<table id="myTable">
<tr>
  <td><b>Row Header:</b></td>
</tr>
<tr>
  <td><input type="text" name="dt1" id="dti1" class="dtpick" value="2011-08-21 01:00:00"></td>
</table><br>
<a onclick="addItem()"> Add another</a> 
</body>
</html>

Any assistance is greatly appreciated!

David

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:51:28+00:00Added an answer on May 24, 2026 at 8:51 pm

    After you’ve appended an item, you need to re-initialize your date picker widget. In other words, it should look like this:

    function addItem() 
    {
        var t = document.getElementById('myTable');
        var row = t.insertRow(-1);
        var c1 = row.insertCell(0);
    
        var c1content=document.createElement("input");
        c1content.setAttribute("type","text");
        c1content.setAttribute("name","dtnew");
        c1content.setAttribute("id","dtinew");  
        c1content.setAttribute("class","dtpick");
        c1content.setAttribute("value","2011-08-20 01:00:00");
    
        c1.appendChild(c1content);
    
        $('.dtpick').datetime({
            userLang: 'en',
            americanMode: true});
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to figure out how to dynamically populate a table without refreshing the
I'm trying to figure out how to resolve relatively referenced resources inside dynamically loaded
I am trying to figure out how I can update my sql query dynamically.
Given a straightforward jQuery Autocomplete, I'm trying to figure out how to dynamically add
I'm trying to figure out how to have a div dynamically resize, based on
I'm trying to figure out if it's possible when you are dynamically generating assemblies,
I'm trying to figure out how to dynamically create methods class MyClass def initialize(dynamic_methods)
Ultimately I am just trying to figure out how to dynamically allocate heap memory
Using the jqGrid i am trying to figure out how to dynamically load my
I'm trying to figure out how to pass 2D array, which is constructed dynamically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.