...

View Full Version : AJAX and JS date input



tjfoz
12-13-2010, 07:54 PM
Hello All,

I am using a JS date input script (http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.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!



$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.

rnd me
12-13-2010, 08:39 PM
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.

tjfoz
12-13-2010, 09:55 PM
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.

rnd me
12-13-2010, 10:30 PM
if newHTML was the text you are injecting,
eval((newHTML.match(/<script[^>]*>([\s\S]*?)<\/script>/gmi)||[]).join("\n"));

tjfoz
12-14-2010, 03:59 PM
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!

rnd me
12-15-2010, 04:53 AM
hard to say, post the generated html and i'll take a look.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum