Jump to content

Add jQuery date picker from PHP (via AJAX call)


everisk

Recommended Posts

Hi,

 

I am using jQuery date picker from http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/. It works great but then I have a function where user can add more row in the table (via AJAX and PHP) and in the new row should also have the date picker. However, the date picker broke and just doesnot show up in the new row. Please help~

 

Many thanks in advance.

 

Below is cut from my code

<head>
<link type="text/css" rel="stylesheet" href="datePicker.css">
<!-- jQuery -->
<script type="text/javascript" src="Scripts/jquery-1.2.1.js"></script>
<!-- required plugins -->
<script type="text/javascript" src="Scripts/date.js"></script>
<!-- jquery.datePicker.js -->
<script type="text/javascript" src="Scripts/jquery.datePicker.js"></script>
<script type="text/javascript" charset="utf-8">
$(function()
{
$('input.date-pick').datePicker({startDate:'01/01/2005'}).val(new Date().asString()).trigger('change');
$('input.calendar-start').datePicker({startDate:'01/<?php print date("m");?>/<?php print date("Y");?>'});
});

</script>
</head>

<body>

<table>
<tr>
<td><input type="input" name="start_date[0]" id="start_date[0]" size="11" maxlength="10" class="calendar-start" value=" "  /></td>
</tr>
<tr>
    <td><a href="javascript:addMoreRow();">[add more row]</a> | <a href="javascript:removeRow();">[remove row]</a></td>
  </tr>
</table>
</body>

 

 

In the PHP file to add more row

 

Nothing in the head section .. just some PHP code . .no javascript call to jQuery . I did try to add javascript call to jQuery and etc. but still it doesn't work

<table>
<tr>
<td><input type="input" name="start_date[<?php print $sno;?>]" id="start_date[<?php print $sno;?>]" size="10" maxlength="10" class="calendar-start" value="" /></td>
</tr>
</table>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.