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 6779625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:24:28+00:00 2026-05-26T16:24:28+00:00

The problem is here i can’t add datepick(); functionality to newly created items. Everythig

  • 0

The problem is here i can’t add datepick(); functionality to newly created items.

Everythig works fine except that.

The first elements which named as date1 and datep1 are has datepick and works so good.

I got the plugin there: http://keith-wood.name/datepick.html What is wrong?

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
        <link rel="stylesheet" type="text/css" media="screen" href="../../../includes/my_app/js/datepick/humanity.datepick.css" /> 
        <script type="text/javascript" src="../../../includes/my_app/js/datepick/jquery.datepick.js"></script>
        <script type="text/javascript" src="../../../includes/my_app/js/datepick/jquery.datepick-tr.js"></script>
        <link rel="stylesheet" type="text/css" media="screen" href="../../../includes/my_app/js/datepick/ui-ui-lightness.datepick.css" /> 
        <script>
            $(function() {
                $('#date1').datepick({
                    dateFormat: 'yyyy-mm-dd',
                    yearRange: '1800:2053'
                });
            });
            $(function() {
                $('#datep1').datepick({
                    dateFormat: 'yyyy-mm-dd',
                    yearRange: '1800:2053'
                });
            });
        </script>
    </head>

    <body>
        <form name="stad_alt" id="myForm">
            <h1></h1>

            <div id="first">
                Please Select:
                <select name="myoption">
        <option value="1">First Option</option> 
                </select><br /><br /></div>
            <div id="container">
                <div id="input1" style="margin-bottom:4px;" class="alternate">
                    Name 1: <input type="text" name="the_name1" id="name1" class="textbox" />
                    From :<input type="text" id="date1" name="from1" class="textbox" />
                    To :<input type="text" id="datep1" name="to1" class="textbox" />
                        Photo: <input type="file" id="photo1" name="photo1" class="textbox" />
                </div>

            </div>

            <div>
                <input type="button" id="add" value="Add New" />
                <input type="button" id="delete" value="Delete This" />
            </div>
        </form>

        <script type="text/javascript">
            $(function(){
                var num = 1; //default 1 
                if (num == 1)
                    $('#delete').prop('disabled','disabled');
                $('#add').live('click',function(e) {
                    e.preventDefault();
                    num = num+1;
                    $('#delete').prop('disabled','');
                    $('#date' + num).datepick({
                    dateFormat: 'yyyy-mm-dd',
                    yearRange: '1800:2053'
                    });
                    $('#datep' + num).datepick({
                    dateFormat: 'yyyy-mm-dd',
                    yearRange: '1800:2053'
                    });                    
                    var html = '<div id="input'+num+'" style="margin-bottom:4px;" class="alternate">Name '+num+': <input type="text" name="the_name'+num+'" id="name'+num+'" class="textbox" /> From :<input type="text" id="date'+num+'" name="from'+num+'" class="textbox" /> To :<input type="text" id="datep'+num+'" name="to'+num+'" class="textbox" /> Photo: <input type="file" id="photo'+num+'" name="photo'+num+'" class="textbox" /></div>';

                    $('#container').append('<div id="input'+num+'" style="margin-bottom:4px;" class="alternate">'+html+'</div>');
                    if (num == 10)
                        $('#add').prop('disabled','disabled');
                });

                $('#delete').click(function() {

                    $('#input' + num).remove();
                    num = num -1;
                    if (num == 1)
                        $('#delete').prop('disabled','disabled');
                    $('#add').prop('disabled','');
                });
            });
        </script>

    </body>
</html>
  • 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-26T16:24:29+00:00Added an answer on May 26, 2026 at 4:24 pm

    You’ve got a lot of structural problems there, making the document a mess; this makes troubleshooting more difficult.

    First things first, get rid of those numerous $(function() { blocks – condense your javascript into one block, at the bottom of the page. CSS in the head, javascript includes at the very end of the body, followed by page script.

    Your immediate problem is called because when you do this:

    $('#date' + num).datepick({
        dateFormat: 'yyyy-mm-dd',
        yearRange: '1800:2053'
    });
    $('#datep' + num).datepick({
        dateFormat: 'yyyy-mm-dd',
        yearRange: '1800:2053'
    });
    
    var html = '<div id="input'+num+'" style="margin-bottom:4px;" class="alternate">Name '+num+': <input type="text" name="the_name'+num+'" id="name'+num+'" class="textbox" /> From :<input type="text" id="date'+num+'" name="from'+num+'" class="textbox" /> To :<input type="text" id="datep'+num+'" name="to'+num+'" class="textbox" /> Photo: <input type="file" id="photo'+num+'" name="photo'+num+'" class="textbox" /></div>';
    

    … putting aside the messy long HTML string (use DOM objects to add content to the page), the problem here is that you are calling the datepick method on an element that does not yet exist on the page. The big line of HTML creation should go BEFORE you try to interact with it. Thus:

    var html = '<div id="input'+num+'" style="margin-bottom:4px;" class="alternate">Name '+num+': <input type="text" name="the_name'+num+'" id="name'+num+'" class="textbox" /> From :<input type="text" id="date'+num+'" name="from'+num+'" class="textbox" /> To :<input type="text" id="datep'+num+'" name="to'+num+'" class="textbox" /> Photo: <input type="file" id="photo'+num+'" name="photo'+num+'" class="textbox" /></div>';
    $('#container').append('<div id="input'+num+'" style="margin-bottom:4px;" class="alternate">'+html+'</div>');
    
    $('#date' + num).datepick({
        dateFormat: 'yyyy-mm-dd',
        yearRange: '1800:2053'
    });
    $('#datep' + num).datepick({
        dateFormat: 'yyyy-mm-dd',
        yearRange: '1800:2053'
    });
    

    Now some homework:

    document.createElement – Use this instead of big messy HTML strings

    Script position – The article is related to performance, but being organized will help YOUR performance as a developer

    Divitis – You’ve got DIVs coming out the wazoo and this is a pretty short page. Take better advantage of CSS

    Avoid inline styles – You’ve got stylesheets attached… use em!

    Use Jquery’s document.ready – those $(function() { things… yuck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the problem I'm having, I've got a set of logs that can grow
I know that can co-exists with web form no problem as Hanselman mention here
HI Guys, Here I am having problem that How can I post an image
I seem to have a bit of a problem here that I can't quite
Same problem as here ( Can't archive anymore, yet "build for archive" still works
Having a problem here.... I can't seem to find a good way to 'add'
I have a small problem here and hope that someone can help me out.
What can be the problem here?
Can check out here alt text http://51hired.com/static/problem.bmp
Well here's my problem I have three tables; regions, countries, states. Countries can be

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.