Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2010
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    AJAX and JS date input

    Hello All,

    I am using a JS date input script (http://www.dynamicdrive.com/dynamici...oncalendar.htm) that I have been using successfully for years. This is the first time I have tried to place it into an AJAX loaded page and it does not display. The code snippet below is loaded into the page via AJAX, as I said, and I can see the code on the Firebug console. The js is included in the main page and again in the AJAX page that loads the main page (just for good measure). Any ideas on why my input isn't showing up? Thanks for any help!

    PHP Code:
        $dateVar "inputDate" $i;
        if (empty(
    $inputDate[$i]))
          
    $inputDate[$i] = date("m/d/Y");
        
    $body .= "<td align=center><script>DateInput('" $dateVar "', 'true', 'MM/DD/YYYY', '" $inputDate[$i] . "')</script></td>\n"
    P.S. I have tried other date input scripts as well to no avail.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    scipt tags don't fire when ajax'd in.
    use a regexp to find the tags and eval the content.
    examples abound, and many libraries do it automatically.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #3
    New Coder
    Join Date
    Nov 2010
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the response rnd me. What you are saying makes sense. I'm an experienced php coder but not so experienced with js. Could you point me to a specific example? I did a web search but the pieces are just not coming together for me.

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    if newHTML was the text you are injecting,
    Code:
    eval((newHTML.match(/<script[^>]*>([\s\S]*?)<\/script>/gmi)||[]).join("\n"));
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #5
    New Coder
    Join Date
    Nov 2010
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Where would I place that line of code? Sorry for being a complete blockhead, but I can't seem to figure it out.

    After the HTML is loaded into the <div> tag (in the php page)? As part of the AJAX call before the .send?

    Thanks!

  • #6
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    hard to say, post the generated html and i'll take a look.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •