Wednesday, July 29, 2009

[jQuery] Re: posting onclick a datepicker value

Hi,

I notice you have the TransactionOrderItemID info in the element ID aswell. So why not use that instead of passing it to the onClick handler? Also the changeStartDate looks redundant, here's an example:

http://jsbin.com/ibebi

On Tue, Jul 28, 2009 at 9:14 PM, Natkeeran L.K. <natkeeran@gmail.com> wrote:

Hello:
There is an onclick event that calls the changeStartDate, and passes
in an ID.

'<input class="InfoBoxLong datepicker" type="text" size="7"
id="StartDate_' +  TransactionOrderItemID + '" onClick="changeStartDate
(\'' + TransactionOrderItemID + '\')"  value="' + ActivationStartDate
+ '"></input>' +

First time, it passes in the correct ID to function.  It has the
correct behavior the first time.  But, after that, it keeps the old
item id, even though a new id is received in the function.
       var ItemNoForDate;

       function changeStartDate(ItemNoForDate){
               alert (ItemNoForDate);

               $(".datepicker").datepicker({
               dateFormat: 'yy-mm-dd',
               onClose: function(dataText, inst){
               $.ajax({
                       type: "POST",
                       url: "php/ChangeStartDate.php",
                       data: "NewDate=" + dataText + "&ItemInfo=" + ItemNoForDate,
                       success: function(msg){
                                       alert (msg);
                       }
                       });
               }
               });

       }
Any feedback on this is appreciated.  Thanks.


Regards,
Nat



--
Ca-Phun Ung
+ http://yelotofu.com
+ hongkong, zce, jquery, jqueryui, php, css, html

No comments: