SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JQuery DatePicker

    Hello list, I am relatively new at JS and also JQuery and am having some problems with configuring the stock datepicker object.

    Here is my class structure:
    Code:
    var accounting = 
    {
        init: function()
        {
            var invDate = $("#invDate");
            for(var i = 0, ii = invDate.length; i < ii; i++){
                // an existing date in an input element, format like 'mm-dd-yy'
                idte = document.getElementById('invDate').value;
                invDate.datepicker();
                invDate.datepicker({
                    dateFormat:"mm-dd-yy",
                    minDate: -20, 
                    maxDate: "+1M +10D",
                    showAnim: "fadeIn",
                    altField: "#actualDate",
                    changeMonth: true,
                    numberOfMonths: 3,
                    showButtonPanel: true
                });
                $(invDate).DatePicker("setDate", idte); // fails here
                $(invDate).bind("change", accounting.doInvDate);
            }
          },
         doInvDate: function(event){
            // never gets here
            var dte = $(this).DatePicker("getDate");
            alert('INV Date has changed, returned value is: '+ dte);
        }
    }
    accounting.init();
    This will create the date picker object so that when the input cell is selected, the datepicker object opens, but I cannot set the date. Also, I would like to get the 3 months showing when the cell is selected, but that never happens either.


    Any suggestions?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by radi8 View Post
    Any suggestions?
    Since there are several things about the page that can interfere with the proper working of the script, can you please provide a test web page that demonstrates the problem so that we can then investigate the cause of that problem.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Nov 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The solution was to remove the invDate.datepicker(); invocation. In essence, I was instantiating the object twice and the second set of instructions were being ignored.


Bookmarks

Posting Permissions

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