+ Reply to Thread
Results 1 to 6 of 6
Like Tree2Likes
  • 1 Post By diabolo
  • 1 Post By descalzo

Thread: JS jQuery datepicker Help Needed

  1. #1
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    JS jQuery datepicker Help Needed

    well im using this script right here:
    http://www.kelvinluck.com/assets/jqu...icker/v2/demo/

    and I have a multiMonth(http://www.kelvinluck.com/assets/jqu...ltiMonth3.html) plugin and multiple select enabled(http://www.kelvinluck.com/assets/jqu...rMultiple.html).


    I want to be able to on load have certain dates already selected and those dates come from a database.
    I found two possible clues to help me out, but since I have not strictly learned JS yet, I can not made heads or tails.
    http://www.kelvinluck.com/assets/jqu...kHolidays.html
    http://www.kelvinluck.com/assets/jqu...aultToday.html

    here's the code right now im using:
    Code:
    <script type="text/javascript" charset="utf-8">
       jQuery(function() {
          jQuery('#multimonth').datePickerMultiMonth({
             numMonths: 12,
             inline: true,
             selectMultiple: true,
             startDate: '01/09/2009', // DD/MM/YY
             month: 8, // 0=JAN  1=FEB ...
             year: 2009
          }).bind(
             'dpMonthChanged',
             function(event, displayedMonth, displayedYear) {
              //uncomment if you have firebug and want to confirm this works as expected...
              //console.log('dpMonthChanged', arguments);
          }).bind(
             'dateSelected',
             function(event, date, jQuerytd, status) {
             //uncomment if you have firebug and want to confirm this works as expected...
             //console.log('dateSelected', arguments);
          }).val(
             new Date().asString()).trigger('change');
          jQuery('#getSelected').bind(
             'click',
             function(e) {
                alert(jQuery('#multimonth').dpmmGetSelected());
                return false;
          });
       });
       </script>

    Code:
    .val(new Date().asString()).trigger('change');
    and this part is not being selected, I took it from the select todays date demo



    and as a bonus, if anyone has any ideas to speed up the load, because right now the page takes forever to load, and I don't have anything to show any progress, so the end user might think the thing is broken.
    dinomirt96 likes this.

  2. #2
    Tenant is offline x10Hosting Member Tenant is an unknown quantity at this point
    Join Date
    Jan 2009
    Posts
    13

    Re: JS jQuery datepicker Help Needed

    The datepicker you are using seems that it needs to much work. I know you already have it installed but I would highly suggest working with an easier script.

    I have used this one in a few application I have developed and it works like a dream.

    http://www.mattkruse.com/javascript/...pup/index.html

  3. #3
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: JS jQuery datepicker Help Needed

    Quote Originally Posted by Tenant View Post
    The datepicker you are using seems that it needs to much work. I know you already have it installed but I would highly suggest working with an easier script.

    I have used this one in a few application I have developed and it works like a dream.

    http://www.mattkruse.com/javascript/...pup/index.html
    He wants something that will show several months at once. I don't see where the one you suggest has that feature. He also wants several dates preselected, which is not a feature of that setup either.

    And, to be blunt, the JQuery implementation looks much more professional that the one you suggest (that uses pop-up windows).
    karimirt47 likes this.
    Nothing is always absolutely so.

  4. #4
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: JS jQuery datepicker Help Needed

    okay guys,
    so I found out how to do it.

    but now another problem arises.
    I have a PHP script stuck into the JS code, im not sure if that is already the problem, but the PHP code draws dates out from the db.
    Code:
    <script type="text/javascript" charset="utf-8">
       jQuery(function() {
          jQuery('#multimonth').datePickerMultiMonth({
             numMonths: 12,
             inline: true,
             selectMultiple: true,
             startDate: '01/09/2009', // DD/MM/YY
             month: 8, // 0=JAN  1=FEB ...
             year: 2009
          }).bind(
             'dpMonthChanged',
             function(event, displayedMonth, displayedYear) {
              //uncomment if you have firebug and want to confirm this works as expected...
              //console.log('dpMonthChanged', arguments);
          }).bind(
             'dateSelected',
             function(event, date, jQuerytd, status) {
             //uncomment if you have firebug and want to confirm this works as expected...
             //console.log('dateSelected', arguments);
          });
          <?php
             $sql = "SELECT * FROM nextsession";
             $result = mysql_query($sql);
             while($row = mysql_fetch_array($result)) {
                echo "jQuery('#multimonth').dpmmSetSelected('".date("d/m/y", $row[1])."'); \n";
             }
          ?>
          //jQuery('#multimonth').dpmmSetSelected('22/09/2009');
          //jQuery('#multimonth').dpmmSetSelected('23/09/2009');
          jQuery('#getSelected').bind(
             'click',
             function(e) {
                alert(jQuery('#multimonth').dpmmGetSelected());
                return false;
          });
       });
       </script>
    around the bottom you will see something like this
    jQuery('#multimonth').dpmmSetSelected('22/09/2009');

    the ones that are in comments are the ones that work
    and the PHP ones doesn't

  5. #5
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: JS jQuery datepicker Help Needed

    Code:
    while($row = mysql_fetch_array($result)) {
      echo "jQuery('#multimonth').dpmmSetSelected('".date("d/m/y", $row[1])."'); \n";
     }
    When you run the page, open the source and see what this code snippet actually prints. That will help you find problems. (Debugging 101A)

    Also 'y' prints two digit for the year. 'Y' prints four.
    Last edited by descalzo; 09-23-2009 at 07:34 PM.
    Nothing is always absolutely so.

  6. #6
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: JS jQuery datepicker Help Needed

    thank you descalzo

    I did check the script, but I over looked the year. I just changed it to 'Y' and it works now

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers