Function undefined - InfoPath Dev
in

InfoPath Dev

Function undefined

Last post 09-22-2009 12:49 AM by alfred_62. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-21-2009 11:43 PM

    Function undefined

    Hi guys,

    I am implementing this 

    http://www.infopathdev.com/forums/t/7156.aspx

    But when I copied paste the code and do everything correct, i still cannot run the function. It says its undefined.

    Can anyone tell me whats wrong?

  • 09-22-2009 12:15 AM In reply to

     There are three different methods detailed in that thread.  Which one are you trying to use?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 09-22-2009 12:49 AM In reply to

    Hi Jimmy,

     

    I am trying to implement this one. The one with the business days. I keep on getting function undefined. I have selected javascript as the coding script and created the start_date and end_date date picker. But I keep on getting undefined function. How do I solve this problem.

     

    Thanks a lot.

     

     var nDateStart, nDateEnd;
    var sDateStart, sDateEnd;
    var nDiff, nDiffB;
    var oDiff = XDocument.DOM.selectSingleNode('my:myFields/my:diff');
    var oDiffB = XDocument.DOM.selectSingleNode('my:myFields/my:diffb');

    function msoxd_my_start_date::OnAfterChange(eventObj) {
      // Normalize date format (yyyy-mm-dd -> mm-dd-yyyy)
      sDateStart = eventObj.Site.text.replace(/(\d{4})-(.+)/,'$2-$1');
      if (sDateStart) {
        // Get start date serial number
        nDateStart = Date.parse(sDateStart);
        if (nDateEnd) {
          // Calculate difference (86400000 milliseconds = 1 day)
          nDiff = (nDateStart) ? (nDateEnd-nDateStart)/86400000 : '';
          // How many complete weeks between start and end dates
          // Multiply by 5 to get the number of business days
          nDiffB = (nDiff) ? Math.floor(nDiff/7)*5 : '';
          // Use % operator to get the remaining days
          // Loop through remaining days to add up business days
          for (var i=1, n; i<nDiff%7+1; i++) {
            n = new Date(Date.parse(sDateStart)+86400000*i).getDay();
            if (n>0 && n<6) nDiffB++;
          }
          oDiff.text = nDiff;
          oDiffB.text = nDiffB;
        }
      }
    }

    function msoxd_my_end_date::OnAfterChange(eventObj) {
      // Normalize date format (yyyy-mm-dd -> mm-dd-yyyy)
      var sDateEnd = eventObj.Site.text.replace(/(\d{4})-(.+)/,'$2-$1');
      if (sDateEnd) {
        // Get end date serial number
        nDateEnd = Date.parse(sDateEnd);
        if (nDateStart) {
          // Calculate difference (86400000 milliseconds = 1 day)
          nDiff = (nDateEnd) ? (nDateEnd-nDateStart)/86400000 : '';
          // How many complete weeks between start and end dates
          // Multiply by 5 to get the number of business days
          nDiffB = (nDiff) ? Math.floor(nDiff/7)*5 : '';
          // Use % operator to get the remaining days
          // Loop through remaining days to add up business days
          for (var i=1, n; i<nDiff%7+1; i++) {
            n = new Date(Date.parse(sDateStart)+86400000*i).getDay();
            if (n>0 && n<6) nDiffB++;
          }
          oDiff.text = nDiff;
          oDiffB.text = nDiffB;
        }
      }
    }

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.