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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:15:58+00:00 2026-06-17T14:15:58+00:00

I have an issue with the date picker, for some reason on first load

  • 0

I have an issue with the date picker, for some reason on first load datepicker works fine and lets me pick the date, but when I click on refresh (via ajax), the datepicker area is refreshed but then i am unable to use the datepicker. Is their anyway around it?

Ive tried using different id and removing the old element with not much success :/

I have a function in php that displays date, in file ‘datefunction.php’

    function getDateInfo()
{
     $date = $_GET['date'];

     $html = '<script> 
        $(document).load(function() {
        $("#dt").datepicker(\'destroy\');
        $("#dt").remove();

        var mydate = $("#dt1").datepicker({ dateFormat: "dd-mm-yy" });
                $("#dt1").click(function(){
                     mydate.datepicker("show");
                     });     
                });
            });</script>
                <label>Date1:</label>
          <input type="text" name="dt"  id="dt1" maxlength="10" size="12" value="' . $date . '" readonly="true" />';

     return $html;
}

echo getDateInfo();

I have page that is viewed called ‘dates.php’

<script src="/script/jquery.js" type="text/javascript"></script>
<script type='text/javascript' src='/script/jquery-ui-1.8.9.custom.min.js'></script>
<script type='text/javascript' src='/script/jquery.datePicker.js'></script>
<script>
var bustcachevar=1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
var bustcacheparameter="";

function ajaxpage(url, containerid, requesttype){
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
        page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
        try {
            page_request = new ActiveXObject("Msxml2.XMLHTTP")
        } 
        catch (e){
            try{
                page_request = new ActiveXObject("Microsoft.XMLHTTP")
            }
            catch (e){}
        }
    } else  return false
    page_request.onreadystatechange=function(){
        loadpage(page_request, containerid)
    }

    if (requesttype=='get'){
        if (bustcachevar) bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
        page_request.open('GET', url+bustcacheparameter, true)
        page_request.send(null)
    } else if (requesttype=='post') {
        var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) + "&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );
        page_request.open('POST', url, true);
        page_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        page_request.setRequestHeader("Content-length", parameters.length);
        page_request.setRequestHeader("Connection", "close");
        page_request.send(parameters);
    };
}

function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=page_request.responseText
}
$(document).ready(function() {
                var mydate = $("#dt").datepicker({ dateFormat: "dd-mm-yy" });
                $("#dt").click(function(){
                     mydate.datepicker("show");
                     });     
                });
</script>


<?php 
$date = "05-06-2009";
echo "<div id='datearea'><label>Date:</label>
          <input type='text' name='dt' id='dt' maxlength='10' size='12' value='" . $date . "' readonly='true' /></div>";
echo "<a href='#' onclick='javascript:ajaxpage(\"datefunction.php?date=02-04-1999\", \"datearea\", \"get\");'>update</a>";
?>
  • 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-06-17T14:16:00+00:00Added an answer on June 17, 2026 at 2:16 pm

    This is because, when the page loads, JQuery *adds* all the events and functions to the DOM elements, but when a an element of DOM is loaded via Ajax it never adds the event. For that to work, I uses LiveQuery plugin of JQuery, that adds the events to DOM even if they are added after the DOM is already loaded that is via AJAX or anything.

    $("#dt").livequery('click', function(event) { 
        //CODE FOR DATE PICKER 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can't find solution to this issue. So i have datepicker input field, it works
The page works fine in Chrome, but I have this one minor error in
I know there is a very similar issue datepicker , but I have not
I have a piece of jQuery that will not load at all for some
I have an issue in making datepicker regional. <script type=text/javascript> $(document).ready(function () { $(function
I have an issue trying to create a dialog on event on click of
Ok I'm using the jQuery Mobile Framework and adding the Experimental Date Picker but
I have some code which works out the time from today until a given
I have a issue with a Jquery DatePicker popup dialog being clipped by an
I'm using the jQuery datepicker to select dates. It works fine, except there is

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.