help with recusion in DOM

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Barry

    #1

    help with recusion in DOM

    I know this is not a php question. If that bothers you, don't respond. If
    not, I sure could use the advice...

    I'm using a very abbreviated set of code to show a calendar. The idea is to
    simply hide the calendar when it loses focus. I'm displaying the calendar in
    a span tag. When that span loses focus, I recurse through its children. If
    focus was lost to a child, then I want to keep the calendar visible. I'm
    using the element.all to determine children of a given node. The problem is
    that changing the months either with the navigation arrows or via the
    drop-down, or by changing the year via its drop-down, the menu
    disappears...ap parently the navigation links and the select's options are
    not seen as a descendant of the primary span tag displaying the calendar.

    (Sorry for the text-wrapping...and tia for any thoughts)

    Here's a snippet of the html using the calendar:

    =============== ======

    <input class="value"
    name="programEx itDate"
    maxlength="255"
    style="text-align:left; width:150px;"
    type="text"
    autocomplete="o ff"
    value="<?= $programExitDat e ?>"
    onblur="formatD ate(this);"
    >
    <img
    src="<?= site::$imagesDi rectory ?>calendar.gif "
    style="cursor:p ointer;"
    title="Click For Calendar"
    onclick="getDat e('programExitC alendar', 'programExitDat e');"
    >
    <span id="programExit Calendar" style="display: none;
    postition:relat ive;"></span>


    =============== ======

    Here's the javascript being called:

    =============== ======

    String.prototyp e.repeat = function(l){ var s = '', i = 0; while (i++ <
    l){ s += this; } return s; }
    String.prototyp e.zf = function(l){ return '0'.repeat(l -
    this.length) + this; }
    Date.prototype. format = function(f)
    {
    if (!this.valueOf( )){ return this.toString() ; }
    var date = this;
    var days = new Array(
    'Sunday' ,
    'Monday' ,
    'Tuesday' ,
    'Wednesday' ,
    'Thursday' ,
    'Friday' ,
    'Saturday'
    );
    var months = new Array(
    'January' ,
    'February' ,
    'March' ,
    'April' ,
    'May' ,
    'June' ,
    'July' ,
    'August' ,
    'September' ,
    'October' ,
    'November' ,
    'December'
    );
    return f.replace(
    /(yyyy|mmmm|mmm| mm|dddd|ddd|dd| hh|nn|ss|a\/p)/gi ,
    function($1)
    {
    switch ($1.toLowerCase ())
    {
    case 'yyyy' : return date.getFullYea r();
    case 'mmmm' : return months[date.getMonth()];
    case 'mmm' : return
    months[date.getMonth()].substr(0, 3);
    case 'mm' : return new String(date.get Month() +
    1).zf(2);
    case 'dddd' : return days[date.getDay()];
    case 'ddd' : return days[date.getDay()].substr(0,
    3);
    case 'dd' : return new
    String(date.get Date()).zf(2);
    case 'hh' : return new String((h = date.getHours()
    % 12) ? h : 12).zf(2);
    case 'nn' : return new
    String(date.get Minutes()).zf(2 );
    case 'ss' : return new
    String(date.get Seconds()).zf(2 );
    case 'a/p' : return date.getHours() < 12 ? 'AM' :
    'PM';
    }
    }
    );
    }

    function formatDate(inpu t)
    {
    if (!input) { return false; }
    if (!input.value) { return false; }
    if (input.value == ''){ return false; }
    var val = new String(input.va lue);
    var month = new String('01');
    var day = new String('01');
    var year = new String('2000');
    val = val.replace(/^(\d{1,2})[^\d]+(\d{1,2})[^\d]+(\d{4})$/,
    "$1/$2/$3");
    if (!isDate(val))
    {
    val = input.value;
    val = val.replace(/^(\d{4})[^\d]+(\d{1,2})[^\d]+(\d{1,2})$/,
    "$2/$3/$1");
    }
    if (!isDate(val))
    {
    input.value = '';
    return false;
    }
    month = "0" + val.replace(/^(\d{1,2})[^\d]+(\d{1,2})[^\d]+(\d{4})$/,
    "$1");
    day = "0" + val.replace(/^(\d{1,2})[^\d]+(\d{1,2})[^\d]+(\d{4})$/,
    "$2");
    year = val.replace(/^(\d{1,2})[^\d]+(\d{1,2})[^\d]+(\d{4})$/,
    "$3");
    val = month.substr(mo nth.length - 2, 2) + "/" +
    day.substr(day. length - 2, 2) + "/" + year;
    input.value = val;
    return true;
    }

    function getDate(parent, target)
    {
    parent = document.getEle mentById(parent );
    target = document.getEle mentById(target );
    if (!parent){ return false; }
    if (!target){ return false; }
    var currentDate = isDate(target.v alue) ? new Date(target.val ue) : new
    Date();
    target.value = isDate(target.v alue) ? target.value : '';
    parent.onblur = function()
    {
    if (isChild(parent ,
    document.active Element)){ return; }
    parent.style.di splay = 'none';
    parent.innerHTM L = '';
    };
    showCalendar(pa rent.id, target.name, currentDate.get FullYear(),
    currentDate.get Month());
    return false;
    }

    function isChild(parent, element)
    {
    if (element == parent){ return true; }
    var children = parent.all;
    for (var child in children)
    {
    var node = children[child];
    if (element == node){ return true; }
    if (node.all)
    {
    if (isChild(node, element)){ return true; }
    }
    }
    return false;
    }
    function showCalendar(sh owIn, returnTo, year, month, day)
    {
    showIn = document.getEle mentById(showIn );
    returnTo = document.getEle mentById(return To);
    if (!showIn){ return false; }
    if (!returnTo){ return false; }
    showIn.style.po sition = 'absolute';
    showIn.style.di splay = '';
    if (day)
    {
    showIn.onblur = null;
    showIn.style.di splay = 'none';
    showIn.innerHTM L = '';
    var date = new Date((month + 1) + '/' + day + '/' + year);
    returnTo.value = date.format('mm/dd/yyyy');
    returnTo.focus( );
    returnTo.select ();
    return false;
    }
    if (showIn.innerHT ML)
    {
    showIn.innerHTM L = '';
    return;
    }
    var link = null;
    var months = new Array(
    'January' ,
    'February' ,
    'March' ,
    'April' ,
    'May' ,
    'June' ,
    'July' ,
    'August' ,
    'September' ,
    'October' ,
    'November' ,
    'December'
    );
    var thisDate = new Date();
    year = year < 2000 ? 2000 : year;
    year = year 2037 ? 2037 : year;
    thisDate.setYea r(year);
    thisDate.setMon th(month);
    thisDate.setDat e(1);
    var days = 32 - new Date(year, month, 32).getDate();
    var nextDate = new Date(year, month, days + 1);
    var lastDate = new Date(year, month, 0);
    lastDate.setDat e(1);
    var today = new Date();
    var todayDay = today.getDate() ;
    var todayMonth = today.getMonth( );
    var todayYear = today.getFullYe ar();
    var html = '';
    html += '<table style="border:1 px solid steelblue; margin:2px;
    padding:2px; width:225px;">\ n';
    html += ' <tr>\n';
    html += ' <td style="backgrou nd-color:#FF9900; font-family:arial;
    font-size:7.25pt; padding-right:5px; padding-top:2px;
    text-align:right;">\ n';
    html += ' <a\n';
    html += ' href=""\n';
    html += ' onclick="showCa lendar(\'' + showIn.id + '\', \'' +
    returnTo.name + '\', ' + lastDate.getFul lYear() + ', ' + lastDate.getMon th()
    + ')"\n';
    html += ' title="Previous Month"\n';
    html += ' ><img src="/images/arrow.left.gif"
    style="border:n one;"></a>\n';
    html += ' </td>\n';
    html += ' <td colspan="5" style="backgrou nd-color:#FF9900;
    padding-top:2px; text-align:center;"> \n';
    html += ' <select\n';
    html += ' style="font-family:arial; font-size:7.25pt;
    text-align:center; width:85px;"\n' ;
    html += ' onchange="showC alendar(\'' + showIn.id + '\', \'' +
    returnTo.name + '\', ' + thisDate.getFul lYear() + ', this.value)"\n' ;
    html += ' >\n';
    for (month in months)
    {
    var selected = month == thisDate.getMon th() ? 'selected' : '\n';
    html += ' <option value="' + month + '" ' + selected + '>' +
    months[month] + '</option>\n';
    }
    html += ' </select>\n';
    html += ' <select\n';
    html += ' style="font-family:arial; font-size:7.25pt;
    text-align:center; width:50px;"\n' ;
    html += ' onchange="showC alendar(\'' + showIn.id + '\', \'' +
    returnTo.name + '\', this.value, ' + thisDate.getMon th() + ')"\n';
    html += ' >\n';
    for (year = 2000; year < 2038; year++)
    {
    var selected = year == thisDate.getFul lYear() ? 'selected' : '\n';
    html += ' <option value="' + year + '" ' + selected + '>' + year +
    '</option>\n';
    }
    html += ' </select>\n';
    html += ' </td>\n';
    html += ' <td style="backgrou nd-color:#FF9900; font-size:7.25pt;
    padding-left:5px; padding-top:2px; text-align:left;">\n ';
    html += ' <a\n';
    html += ' href=""\n';
    html += ' onclick="showCa lendar(\'' + showIn.id + '\', \'' +
    returnTo.name + '\', ' + nextDate.getFul lYear() + ', ' + nextDate.getMon th()
    + ')"\n';
    html += ' title="Next Month"\n';
    html += ' ><img src="/images/arrow.right.gif "
    style="border:n one;"></a>\n';
    html += ' </td>\n';
    html += ' <tr><td colspan="7" style="backgrou nd-color:#FF9900;
    border-bottom:1px solid lavender; height:2px;"></td></tr>\n';
    html += ' <tr>\n';
    html += ' <td style="font-size:7.25pt; font-weight:600;
    text-align:center; width:25px;">Su n</td>\n';
    html += ' <td style="font-size:7.25pt; font-weight:600;
    text-align:center; width:25px;">Mo n</td>\n';
    html += ' <td style="font-size:7.25pt; font-weight:600;
    text-align:center; width:25px;">Tu e</td>\n';
    html += ' <td style="font-size:7.25pt; font-weight:600;
    text-align:center; width:25px;">We d</td>\n';
    html += ' <td style="font-size:7.25pt; font-weight:600;
    text-align:center; width:25px;">Th u</td>\n';
    html += ' <td style="font-size:7.25pt; font-weight:600;
    text-align:center; width:25px;">Fr i</td>\n';
    html += ' <td style="font-size:7.25pt; font-weight:600;
    text-align:center; width:25px;">Sa t</td>\n';
    html += ' </tr>\n';
    html += ' <tr><td colspan="7" style="border-bottom:1px solid lavender;
    height:2px;"></td></tr>\n';
    html += ' <tr>\n';
    month = thisDate.getMon th();
    year = thisDate.getFul lYear();
    var daysLeft = 0;
    var weekDay = thisDate.getDay ();
    if (weekDay 0)
    {
    html += ' <td colspan="' + weekDay + '"
    style="backgrou nd-color:lavender; font-size:7.25pt;
    width:25px;">&n bsp;</td>\n';
    }
    for (var day = 1; day <= days; day++)
    {
    for (; weekDay < 7; weekDay++)
    {
    if (day days)
    {
    daysLeft++;
    continue;
    }
    if (!weekDay)
    {
    html += ' </tr>\n';
    html += ' <tr>\n';
    }
    var border = 'none';
    var fontWeight = '100';
    if (day == todayDay && month == todayMonth && year == todayYear)
    {
    border = '1px solid #990000';
    fontWeight = '600';
    }
    html += '<td style="border:' + border + 'font-size:7.25pt;
    width:20px;">\n ';
    html += ' <a\n';
    html += ' href="' + day + '"\n';
    html += ' style="font-weight:' + fontWeight + ';
    text-decoration:none ;"\n';
    html += ' onclick="return showCalendar(\' ' + showIn.id + '\',
    \'' + returnTo.name + '\', ' + year + ', ' + month + ', ' + day + ')"\n';
    html += ' >' + day + '</a>\n';
    html += '</td>\n';
    day++
    }
    day--;
    weekDay = 0;
    }
    if (daysLeft 0)
    {
    html += ' <td colspan="' + daysLeft + '"
    style="backgrou nd-color:lavender; width:25px;">&n bsp;</td>\n';
    }
    html += ' </tr>\n';
    html += '</table>\n';
    showIn.innerHTM L = html;
    showIn.focus();
    return false;
    }


    =============== ======


  • Barry

    #2
    Re: help with recusion in DOM

    forgot that the code above also calls isDate...

    function isDate(val)
    {
    if (!val) { return false; }
    if (val == ""){ return false; }
    var re = new
    RegExp(/^(?:\s+)?(?=\d) (?:(?:(?:(?:(?: 0?[13578]|1[02])(\/|-|\.)31)\1|(?:(? :0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2 ))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0 ?2(\/|-|\.)29\3(?:(?:( ?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0 ?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|
    (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(( [AP]M)|(
    [ap]m)))|([01]\d|2[0-3])(:[0-5]\d){1,2})?(?:\s +)?$/);
    return re.test(val);
    }


    Comment

    • Jerry Stuckle

      #3
      Re: help with recusion in DOM

      Barry wrote:
      I know this is not a php question. If that bothers you, don't respond. If
      not, I sure could use the advice...
      >
      I'm using a very abbreviated set of code to show a calendar. The idea is to
      simply hide the calendar when it loses focus. I'm displaying the calendar in
      a span tag. When that span loses focus, I recurse through its children. If
      focus was lost to a child, then I want to keep the calendar visible. I'm
      using the element.all to determine children of a given node. The problem is
      that changing the months either with the navigation arrows or via the
      drop-down, or by changing the year via its drop-down, the menu
      disappears...ap parently the navigation links and the select's options are
      not seen as a descendant of the primary span tag displaying the calendar.
      >
      (Sorry for the text-wrapping...and tia for any thoughts)
      >
      <snip>

      Ask in an appropriate newsgroup and you'll get a good answer.

      As you said - this isn't a PHP problem, so this is not the appropriate
      newsgroup.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Barry

        #4
        Re: help with recusion in DOM


        "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
        news:LMOdnbj3jv BWE_jVnZ2dnUVZ_ rydnZ2d@comcast .com...
        Barry wrote:
        >I know this is not a php question. If that bothers you, don't respond. If
        >not, I sure could use the advice...
        >>
        >I'm using a very abbreviated set of code to show a calendar. The idea is
        >to simply hide the calendar when it loses focus. I'm displaying the
        >calendar in a span tag. When that span loses focus, I recurse through its
        >children. If focus was lost to a child, then I want to keep the calendar
        >visible. I'm using the element.all to determine children of a given node.
        >The problem is that changing the months either with the navigation arrows
        >or via the drop-down, or by changing the year via its drop-down, the menu
        >disappears...a pparently the navigation links and the select's options are
        >not seen as a descendant of the primary span tag displaying the calendar.
        >>
        >(Sorry for the text-wrapping...and tia for any thoughts)
        >>
        >
        <snip>
        >
        Ask in an appropriate newsgroup and you'll get a good answer.
        >
        As you said - this isn't a PHP problem, so this is not the appropriate
        newsgroup.
        I know, but getting a reponse - much less a timely one - is a bit
        troublesome. As it is, I've figured it out. The problem wasn't recusion for
        child nodes, it was 'remnant' code i'd left in while prototyping...w here I
        was setting the span's innerHTML to ''. It works fine now.

        Thanks anyway.


        Comment

        • Jerry Stuckle

          #5
          Re: help with recusion in DOM

          Barry wrote:
          "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
          news:LMOdnbj3jv BWE_jVnZ2dnUVZ_ rydnZ2d@comcast .com...
          >Barry wrote:
          >>I know this is not a php question. If that bothers you, don't respond. If
          >>not, I sure could use the advice...
          >>>
          >>I'm using a very abbreviated set of code to show a calendar. The idea is
          >>to simply hide the calendar when it loses focus. I'm displaying the
          >>calendar in a span tag. When that span loses focus, I recurse through its
          >>children. If focus was lost to a child, then I want to keep the calendar
          >>visible. I'm using the element.all to determine children of a given node.
          >>The problem is that changing the months either with the navigation arrows
          >>or via the drop-down, or by changing the year via its drop-down, the menu
          >>disappears... apparently the navigation links and the select's options are
          >>not seen as a descendant of the primary span tag displaying the calendar.
          >>>
          >>(Sorry for the text-wrapping...and tia for any thoughts)
          >>>
          ><snip>
          >>
          >Ask in an appropriate newsgroup and you'll get a good answer.
          >>
          >As you said - this isn't a PHP problem, so this is not the appropriate
          >newsgroup.
          >
          I know, but getting a reponse - much less a timely one - is a bit
          troublesome. As it is, I've figured it out. The problem wasn't recusion for
          child nodes, it was 'remnant' code i'd left in while prototyping...w here I
          was setting the span's innerHTML to ''. It works fine now.
          >
          Thanks anyway.
          >
          >
          It's a lot less troublesome to get a response when you ask in the
          correct newsgroup.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Barry

            #6
            Re: help with recusion in DOM


            "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
            news:NOOdnYa6Bo FiCvjVnZ2dnUVZ_ o2dnZ2d@comcast .com...
            Barry wrote:
            >"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
            >news:LMOdnbj3j vBWE_jVnZ2dnUVZ _rydnZ2d@comcas t.com...
            >>Barry wrote:
            >>>I know this is not a php question. If that bothers you, don't respond.
            >>>If not, I sure could use the advice...
            >>>>
            >>>I'm using a very abbreviated set of code to show a calendar. The idea
            >>>is to simply hide the calendar when it loses focus. I'm displaying the
            >>>calendar in a span tag. When that span loses focus, I recurse through
            >>>its children. If focus was lost to a child, then I want to keep the
            >>>calendar visible. I'm using the element.all to determine children of a
            >>>given node. The problem is that changing the months either with the
            >>>navigation arrows or via the drop-down, or by changing the year via its
            >>>drop-down, the menu disappears...ap parently the navigation links and
            >>>the select's options are not seen as a descendant of the primary span
            >>>tag displaying the calendar.
            >>>>
            >>>(Sorry for the text-wrapping...and tia for any thoughts)
            >>>>
            >><snip>
            >>>
            >>Ask in an appropriate newsgroup and you'll get a good answer.
            >>>
            >>As you said - this isn't a PHP problem, so this is not the appropriate
            >>newsgroup.
            >>
            >I know, but getting a reponse - much less a timely one - is a bit
            >troublesome. As it is, I've figured it out. The problem wasn't recusion
            >for child nodes, it was 'remnant' code i'd left in while
            >prototyping... where I was setting the span's innerHTML to ''. It works
            >fine now.
            >>
            >Thanks anyway.
            >
            It's a lot less troublesome to get a response when you ask in the correct
            newsgroup
            Troublesome is not getting a response at all...*from* the correct newsgroup.
            :)


            Comment

            • Jerry Stuckle

              #7
              Re: help with recusion in DOM

              Barry wrote:
              "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
              news:NOOdnYa6Bo FiCvjVnZ2dnUVZ_ o2dnZ2d@comcast .com...
              >Barry wrote:
              >>"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
              >>news:LMOdnbj3 jvBWE_jVnZ2dnUV Z_rydnZ2d@comca st.com...
              >>>Barry wrote:
              >>>>I know this is not a php question. If that bothers you, don't respond.
              >>>>If not, I sure could use the advice...
              >>>>>
              >>>>I'm using a very abbreviated set of code to show a calendar. The idea
              >>>>is to simply hide the calendar when it loses focus. I'm displaying the
              >>>>calendar in a span tag. When that span loses focus, I recurse through
              >>>>its children. If focus was lost to a child, then I want to keep the
              >>>>calendar visible. I'm using the element.all to determine children of a
              >>>>given node. The problem is that changing the months either with the
              >>>>navigatio n arrows or via the drop-down, or by changing the year via its
              >>>>drop-down, the menu disappears...ap parently the navigation links and
              >>>>the select's options are not seen as a descendant of the primary span
              >>>>tag displaying the calendar.
              >>>>>
              >>>>(Sorry for the text-wrapping...and tia for any thoughts)
              >>>>>
              >>><snip>
              >>>>
              >>>Ask in an appropriate newsgroup and you'll get a good answer.
              >>>>
              >>>As you said - this isn't a PHP problem, so this is not the appropriate
              >>>newsgroup.
              >>I know, but getting a reponse - much less a timely one - is a bit
              >>troublesome . As it is, I've figured it out. The problem wasn't recusion
              >>for child nodes, it was 'remnant' code i'd left in while
              >>prototyping.. .where I was setting the span's innerHTML to ''. It works
              >>fine now.
              >>>
              >>Thanks anyway.
              >It's a lot less troublesome to get a response when you ask in the correct
              >newsgroup
              >
              Troublesome is not getting a response at all...*from* the correct newsgroup.
              :)
              >
              >
              So you think you can ask in just any old newsgroup and get an answer?

              That's why there are different newsgroup for different purposes -
              because here we want to talk about PHP and not put up with all of that
              javascript.

              When I want javascript help I got to a javascript newsgroup.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              • Barry

                #8
                Re: help with recusion in DOM


                "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
                news:R9qdnYTI77 _AAPjVnZ2dnUVZ_ vSdnZ2d@comcast .com...
                Barry wrote:
                >"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
                >news:NOOdnYa6B oFiCvjVnZ2dnUVZ _o2dnZ2d@comcas t.com...
                >>Barry wrote:
                >>>"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
                >>>news:LMOdnbj 3jvBWE_jVnZ2dnU VZ_rydnZ2d@comc ast.com...
                >>>>Barry wrote:
                >>>>>I know this is not a php question. If that bothers you, don't
                >>>>>respond. If not, I sure could use the advice...
                >>>>>>
                >>>>>I'm using a very abbreviated set of code to show a calendar. The idea
                >>>>>is to simply hide the calendar when it loses focus. I'm displaying
                >>>>>the calendar in a span tag. When that span loses focus, I recurse
                >>>>>through its children. If focus was lost to a child, then I want to
                >>>>>keep the calendar visible. I'm using the element.all to determine
                >>>>>children of a given node. The problem is that changing the months
                >>>>>either with the navigation arrows or via the drop-down, or by
                >>>>>changing the year via its drop-down, the menu disappears...ap parently
                >>>>>the navigation links and the select's options are not seen as a
                >>>>>descenda nt of the primary span tag displaying the calendar.
                >>>>>>
                >>>>>(Sorry for the text-wrapping...and tia for any thoughts)
                >>>>>>
                >>>><snip>
                >>>>>
                >>>>Ask in an appropriate newsgroup and you'll get a good answer.
                >>>>>
                >>>>As you said - this isn't a PHP problem, so this is not the appropriate
                >>>>newsgroup .
                >>>I know, but getting a reponse - much less a timely one - is a bit
                >>>troublesom e. As it is, I've figured it out. The problem wasn't recusion
                >>>for child nodes, it was 'remnant' code i'd left in while
                >>>prototyping. ..where I was setting the span's innerHTML to ''. It works
                >>>fine now.
                >>>>
                >>>Thanks anyway.
                >>It's a lot less troublesome to get a response when you ask in the
                >>correct newsgroup
                >>
                >Troublesome is not getting a response at all...*from* the correct
                >newsgroup. :)
                >
                So you think you can ask in just any old newsgroup and get an answer?
                Uhm, no. I wouldn't ask this question in alt.strawmen. But, since web
                developers of all sorts will inevitably use javascript and since I'm using
                php, I thought it better to ask in this php ng rather than, say,
                alt.lang.asp (but would be just as likely get a correct response there as
                well).
                That's why there are different newsgroup for different purposes - because
                here we want to talk about PHP and not put up with all of that javascript.
                Let me clue you in, Jerry...

                "I know this is not a php question. If that bothers you, don't respond."

                In the first two sentences of my OP, you should have put your blinders on
                and gone on to a post you *prefer* to answer...unless , you really prefer to
                waste time in such a manner as you've done in replying to this thread. :)

                Oh, and by "we want", I think you're only speaking for yourself and a narrow
                margin of others..who still may be a bit reluctant to have you as their
                spokesperson.
                When I want javascript help I got to a javascript newsgroup.
                Yep. Me too. But when I don't 'got' a response there, I don't exclude other
                alternatives for fear I may get inane flames...as is evidenciarily proving
                itself out here, now.

                Have a nice day.


                Comment

                • Michael Fesser

                  #9
                  Re: help with recusion in DOM

                  ..oO(Barry)
                  >Uhm, no. I wouldn't ask this question in alt.strawmen. But, since web
                  >developers of all sorts will inevitably use javascript
                  I don't.
                  >and since I'm using
                  >php, I thought it better to ask in this php ng rather than, say,
                  >alt.lang.asp (but would be just as likely get a correct response there as
                  >well).
                  The correct newsgroup would be <news:comp.lang .javascript>. Here it is
                  totally OT.
                  >That's why there are different newsgroup for different purposes - because
                  >here we want to talk about PHP and not put up with all of that javascript.
                  >
                  >Let me clue you in, Jerry...
                  >
                  >"I know this is not a php question. If that bothers you, don't respond."
                  >
                  >In the first two sentences of my OP, you should have put your blinders on
                  >and gone on to a post you *prefer* to answer...unless , you really prefer to
                  >waste time in such a manner as you've done in replying to this thread. :)
                  You know that it's OT and still post it? Maybe you should close your OE
                  for a while and learn something about Usenet and the netiquette first.
                  >Oh, and by "we want", I think you're only speaking for yourself and a narrow
                  >margin of others..who still may be a bit reluctant to have you as their
                  >spokesperson .
                  >
                  >When I want javascript help I got to a javascript newsgroup.
                  >
                  >Yep. Me too. But when I don't 'got' a response there
                  .... then ask again and rephrase your question.
                  >I don't exclude other
                  >alternatives for fear I may get inane flames...as is evidenciarily proving
                  >itself out here, now.
                  What makes you think that you'll get answers to a JS problem in a PHP
                  group? Would you also ask PHP question over in clj if you don't get an
                  answer here?

                  How To Ask Questions The Smart Way


                  EOT
                  Micha

                  Comment

                  • Jeff

                    #10
                    Re: help with recusion in DOM

                    Barry wrote:
                    I know this is not a php question. If that bothers you, don't respond. If
                    not, I sure could use the advice...
                    Barry, you should learn something from this.

                    You've asked an OT question without bothering to ask in the group it
                    would be on topic for. Then you've wasted a lot of time arguing about
                    this. Just look at the length of the thread.

                    BTW, what's with all the inline styles? You could benefit by
                    learning about CSS descendants, a few classes, and adding a small
                    stylesheet. And, don't use points.

                    Jeff

                    >
                    I'm using a very abbreviated set of code to show a calendar. The idea is to
                    simply hide the calendar when it loses focus. I'm displaying the calendar in
                    a span tag. When that span loses focus, I recurse through its children. If
                    focus was lost to a child, then I want to keep the calendar visible. I'm
                    using the element.all to determine children of a given node. The problem is
                    that changing the months either with the navigation arrows or via the
                    drop-down, or by changing the year via its drop-down, the menu
                    disappears...ap parently the navigation links and the select's options are
                    not seen as a descendant of the primary span tag displaying the calendar.
                    >
                    (Sorry for the text-wrapping...and tia for any thoughts)
                    >
                    Here's a snippet of the html using the calendar:
                    >
                    =============== ======
                    >
                    <input class="value"
                    name="programEx itDate"
                    maxlength="255"
                    style="text-align:left; width:150px;"
                    type="text"
                    autocomplete="o ff"
                    value="<?= $programExitDat e ?>"
                    onblur="formatD ate(this);"
                    <img
                    src="<?= site::$imagesDi rectory ?>calendar.gif "
                    style="cursor:p ointer;"
                    title="Click For Calendar"
                    onclick="getDat e('programExitC alendar', 'programExitDat e');"
                    <span id="programExit Calendar" style="display: none;
                    postition:relat ive;"></span>
                    >
                    >
                    =============== ======
                    >
                    Here's the javascript being called:
                    >
                    =============== ======
                    >
                    String.prototyp e.repeat = function(l){ var s = '', i = 0; while (i++ <
                    l){ s += this; } return s; }
                    String.prototyp e.zf = function(l){ return '0'.repeat(l -
                    this.length) + this; }
                    Date.prototype. format = function(f)
                    {
                    if (!this.valueOf( )){ return this.toString() ; }
                    var date = this;
                    var days = new Array(
                    'Sunday' ,
                    'Monday' ,
                    'Tuesday' ,
                    'Wednesday' ,
                    'Thursday' ,
                    'Friday' ,
                    'Saturday'
                    );
                    var months = new Array(
                    'January' ,
                    'February' ,
                    'March' ,
                    'April' ,
                    'May' ,
                    'June' ,
                    'July' ,
                    'August' ,
                    'September' ,
                    'October' ,
                    'November' ,
                    'December'
                    );
                    return f.replace(
                    /(yyyy|mmmm|mmm| mm|dddd|ddd|dd| hh|nn|ss|a\/p)/gi ,
                    function($1)
                    {
                    switch ($1.toLowerCase ())
                    {
                    case 'yyyy' : return date.getFullYea r();
                    case 'mmmm' : return months[date.getMonth()];
                    case 'mmm' : return
                    months[date.getMonth()].substr(0, 3);
                    case 'mm' : return new String(date.get Month() +
                    1).zf(2);
                    case 'dddd' : return days[date.getDay()];
                    case 'ddd' : return days[date.getDay()].substr(0,
                    3);
                    case 'dd' : return new
                    String(date.get Date()).zf(2);
                    case 'hh' : return new String((h = date.getHours()
                    % 12) ? h : 12).zf(2);
                    case 'nn' : return new
                    String(date.get Minutes()).zf(2 );
                    case 'ss' : return new
                    String(date.get Seconds()).zf(2 );
                    case 'a/p' : return date.getHours() < 12 ? 'AM' :
                    'PM';
                    }
                    }
                    );
                    }
                    >
                    function formatDate(inpu t)
                    {
                    if (!input) { return false; }
                    if (!input.value) { return false; }
                    if (input.value == ''){ return false; }
                    var val = new String(input.va lue);
                    var month = new String('01');
                    var day = new String('01');
                    var year = new String('2000');
                    val = val.replace(/^(\d{1,2})[^\d]+(\d{1,2})[^\d]+(\d{4})$/,
                    "$1/$2/$3");
                    if (!isDate(val))
                    {
                    val = input.value;
                    val = val.replace(/^(\d{4})[^\d]+(\d{1,2})[^\d]+(\d{1,2})$/,
                    "$2/$3/$1");
                    }
                    if (!isDate(val))
                    {
                    input.value = '';
                    return false;
                    }
                    month = "0" + val.replace(/^(\d{1,2})[^\d]+(\d{1,2})[^\d]+(\d{4})$/,
                    "$1");
                    day = "0" + val.replace(/^(\d{1,2})[^\d]+(\d{1,2})[^\d]+(\d{4})$/,
                    "$2");
                    year = val.replace(/^(\d{1,2})[^\d]+(\d{1,2})[^\d]+(\d{4})$/,
                    "$3");
                    val = month.substr(mo nth.length - 2, 2) + "/" +
                    day.substr(day. length - 2, 2) + "/" + year;
                    input.value = val;
                    return true;
                    }
                    >
                    function getDate(parent, target)
                    {
                    parent = document.getEle mentById(parent );
                    target = document.getEle mentById(target );
                    if (!parent){ return false; }
                    if (!target){ return false; }
                    var currentDate = isDate(target.v alue) ? new Date(target.val ue) : new
                    Date();
                    target.value = isDate(target.v alue) ? target.value : '';
                    parent.onblur = function()
                    {
                    if (isChild(parent ,
                    document.active Element)){ return; }
                    parent.style.di splay = 'none';
                    parent.innerHTM L = '';
                    };
                    showCalendar(pa rent.id, target.name, currentDate.get FullYear(),
                    currentDate.get Month());
                    return false;
                    }
                    >
                    function isChild(parent, element)
                    {
                    if (element == parent){ return true; }
                    var children = parent.all;
                    for (var child in children)
                    {
                    var node = children[child];
                    if (element == node){ return true; }
                    if (node.all)
                    {
                    if (isChild(node, element)){ return true; }
                    }
                    }
                    return false;
                    }
                    function showCalendar(sh owIn, returnTo, year, month, day)
                    {
                    showIn = document.getEle mentById(showIn );
                    returnTo = document.getEle mentById(return To);
                    if (!showIn){ return false; }
                    if (!returnTo){ return false; }
                    showIn.style.po sition = 'absolute';
                    showIn.style.di splay = '';
                    if (day)
                    {
                    showIn.onblur = null;
                    showIn.style.di splay = 'none';
                    showIn.innerHTM L = '';
                    var date = new Date((month + 1) + '/' + day + '/' + year);
                    returnTo.value = date.format('mm/dd/yyyy');
                    returnTo.focus( );
                    returnTo.select ();
                    return false;
                    }
                    if (showIn.innerHT ML)
                    {
                    showIn.innerHTM L = '';
                    return;
                    }
                    var link = null;
                    var months = new Array(
                    'January' ,
                    'February' ,
                    'March' ,
                    'April' ,
                    'May' ,
                    'June' ,
                    'July' ,
                    'August' ,
                    'September' ,
                    'October' ,
                    'November' ,
                    'December'
                    );
                    var thisDate = new Date();
                    year = year < 2000 ? 2000 : year;
                    year = year 2037 ? 2037 : year;
                    thisDate.setYea r(year);
                    thisDate.setMon th(month);
                    thisDate.setDat e(1);
                    var days = 32 - new Date(year, month, 32).getDate();
                    var nextDate = new Date(year, month, days + 1);
                    var lastDate = new Date(year, month, 0);
                    lastDate.setDat e(1);
                    var today = new Date();
                    var todayDay = today.getDate() ;
                    var todayMonth = today.getMonth( );
                    var todayYear = today.getFullYe ar();
                    var html = '';
                    html += '<table style="border:1 px solid steelblue; margin:2px;
                    padding:2px; width:225px;">\ n';
                    html += ' <tr>\n';
                    html += ' <td style="backgrou nd-color:#FF9900; font-family:arial;
                    font-size:7.25pt; padding-right:5px; padding-top:2px;
                    text-align:right;">\ n';
                    html += ' <a\n';
                    html += ' href=""\n';
                    html += ' onclick="showCa lendar(\'' + showIn.id + '\', \'' +
                    returnTo.name + '\', ' + lastDate.getFul lYear() + ', ' + lastDate.getMon th()
                    + ')"\n';
                    html += ' title="Previous Month"\n';
                    html += ' ><img src="/images/arrow.left.gif"
                    style="border:n one;"></a>\n';
                    html += ' </td>\n';
                    html += ' <td colspan="5" style="backgrou nd-color:#FF9900;
                    padding-top:2px; text-align:center;"> \n';
                    html += ' <select\n';
                    html += ' style="font-family:arial; font-size:7.25pt;
                    text-align:center; width:85px;"\n' ;
                    html += ' onchange="showC alendar(\'' + showIn.id + '\', \'' +
                    returnTo.name + '\', ' + thisDate.getFul lYear() + ', this.value)"\n' ;
                    html += ' >\n';
                    for (month in months)
                    {
                    var selected = month == thisDate.getMon th() ? 'selected' : '\n';
                    html += ' <option value="' + month + '" ' + selected + '>' +
                    months[month] + '</option>\n';
                    }
                    html += ' </select>\n';
                    html += ' <select\n';
                    html += ' style="font-family:arial; font-size:7.25pt;
                    text-align:center; width:50px;"\n' ;
                    html += ' onchange="showC alendar(\'' + showIn.id + '\', \'' +
                    returnTo.name + '\', this.value, ' + thisDate.getMon th() + ')"\n';
                    html += ' >\n';
                    for (year = 2000; year < 2038; year++)
                    {
                    var selected = year == thisDate.getFul lYear() ? 'selected' : '\n';
                    html += ' <option value="' + year + '" ' + selected + '>' + year +
                    '</option>\n';
                    }
                    html += ' </select>\n';
                    html += ' </td>\n';
                    html += ' <td style="backgrou nd-color:#FF9900; font-size:7.25pt;
                    padding-left:5px; padding-top:2px; text-align:left;">\n ';
                    html += ' <a\n';
                    html += ' href=""\n';
                    html += ' onclick="showCa lendar(\'' + showIn.id + '\', \'' +
                    returnTo.name + '\', ' + nextDate.getFul lYear() + ', ' + nextDate.getMon th()
                    + ')"\n';
                    html += ' title="Next Month"\n';
                    html += ' ><img src="/images/arrow.right.gif "
                    style="border:n one;"></a>\n';
                    html += ' </td>\n';
                    html += ' <tr><td colspan="7" style="backgrou nd-color:#FF9900;
                    border-bottom:1px solid lavender; height:2px;"></td></tr>\n';
                    html += ' <tr>\n';
                    html += ' <td style="font-size:7.25pt; font-weight:600;
                    text-align:center; width:25px;">Su n</td>\n';
                    html += ' <td style="font-size:7.25pt; font-weight:600;
                    text-align:center; width:25px;">Mo n</td>\n';
                    html += ' <td style="font-size:7.25pt; font-weight:600;
                    text-align:center; width:25px;">Tu e</td>\n';
                    html += ' <td style="font-size:7.25pt; font-weight:600;
                    text-align:center; width:25px;">We d</td>\n';
                    html += ' <td style="font-size:7.25pt; font-weight:600;
                    text-align:center; width:25px;">Th u</td>\n';
                    html += ' <td style="font-size:7.25pt; font-weight:600;
                    text-align:center; width:25px;">Fr i</td>\n';
                    html += ' <td style="font-size:7.25pt; font-weight:600;
                    text-align:center; width:25px;">Sa t</td>\n';
                    html += ' </tr>\n';
                    html += ' <tr><td colspan="7" style="border-bottom:1px solid lavender;
                    height:2px;"></td></tr>\n';
                    html += ' <tr>\n';
                    month = thisDate.getMon th();
                    year = thisDate.getFul lYear();
                    var daysLeft = 0;
                    var weekDay = thisDate.getDay ();
                    if (weekDay 0)
                    {
                    html += ' <td colspan="' + weekDay + '"
                    style="backgrou nd-color:lavender; font-size:7.25pt;
                    width:25px;">&n bsp;</td>\n';
                    }
                    for (var day = 1; day <= days; day++)
                    {
                    for (; weekDay < 7; weekDay++)
                    {
                    if (day days)
                    {
                    daysLeft++;
                    continue;
                    }
                    if (!weekDay)
                    {
                    html += ' </tr>\n';
                    html += ' <tr>\n';
                    }
                    var border = 'none';
                    var fontWeight = '100';
                    if (day == todayDay && month == todayMonth && year == todayYear)
                    {
                    border = '1px solid #990000';
                    fontWeight = '600';
                    }
                    html += '<td style="border:' + border + 'font-size:7.25pt;
                    width:20px;">\n ';
                    html += ' <a\n';
                    html += ' href="' + day + '"\n';
                    html += ' style="font-weight:' + fontWeight + ';
                    text-decoration:none ;"\n';
                    html += ' onclick="return showCalendar(\' ' + showIn.id + '\',
                    \'' + returnTo.name + '\', ' + year + ', ' + month + ', ' + day + ')"\n';
                    html += ' >' + day + '</a>\n';
                    html += '</td>\n';
                    day++
                    }
                    day--;
                    weekDay = 0;
                    }
                    if (daysLeft 0)
                    {
                    html += ' <td colspan="' + daysLeft + '"
                    style="backgrou nd-color:lavender; width:25px;">&n bsp;</td>\n';
                    }
                    html += ' </tr>\n';
                    html += '</table>\n';
                    showIn.innerHTM L = html;
                    showIn.focus();
                    return false;
                    }
                    >
                    >
                    =============== ======
                    >
                    >

                    Comment

                    • Barry

                      #11
                      Re: help with recusion in DOM


                      "Jeff" <jeff@spam_me_n ot.comwrote in message
                      news:CaadnfT9W-eCCPrVnZ2dnUVZ_ t_inZ2d@earthli nk.com...
                      Barry wrote:
                      >I know this is not a php question. If that bothers you, don't respond. If
                      >not, I sure could use the advice...
                      >
                      Barry, you should learn something from this.
                      >
                      You've asked an OT question without bothering to ask in the group it would
                      be on topic for. Then you've wasted a lot of time arguing about this. Just
                      look at the length of the thread.
                      hey jeff. i actually did ask the question in two javascript newsgroups.
                      after not getting any hits, i asked here. as for my time, i appreciate your
                      consideration thereof.
                      BTW, what's with all the inline styles? You could benefit by learning
                      about CSS descendants, a few classes, and adding a small stylesheet. And,
                      don't use points.
                      i'm doing that now. i worked up a static version so i could tweak the
                      appearance and find what the best patterns were to make into the css
                      classes.

                      btw, what's wrong with points?

                      thanks.


                      Comment

                      • Michael Fesser

                        #12
                        Re: help with recusion in DOM

                        ..oO(Barry)
                        >Grow up, Jerry.
                        Why do you say the same thing the third time? Why do you quote the
                        entire posting the third time? Why don't you just leave and ask your
                        questions in the appropriate newsgroups?

                        Micha

                        Comment

                        • Barry

                          #13
                          Re: help with recusion in DOM


                          "Michael Fesser" <netizen@gmx.de wrote in message
                          news:csmi64hri3 e70e4jealgd4nld iear2ajhj@4ax.c om...
                          .oO(Barry)
                          >
                          >>Grow up, Jerry.
                          >
                          Why do you say the same thing the third time? Why do you quote the
                          entire posting the third time? Why don't you just leave and ask your
                          questions in the appropriate newsgroups?
                          I'm simply amazed that Jerry still feels the need to respond. Seems he's a
                          'last word in' kind of guy. Leaving in the entire post just ensures that
                          other readers know what the comment applies to. As for leaving...nah.

                          Why is this all such a big deal? You and Jerry are both free to ignore the
                          thread. As you stated before, I'm using OE...surely someone with a muuuuch
                          more sophisticated newsreader can figure out how to do that. :)

                          Cheers.


                          Comment

                          • Jerry Stuckle

                            #14
                            Re: help with recusion in DOM

                            Barry wrote:
                            ers again.
                            >
                            Grow up, Jerry.
                            >
                            >
                            >
                            Yep, you need to grow up, Barry. Poor little boy threw a temper tantrum
                            and now needs his diapers changed!


                            --
                            =============== ===
                            Remove the "x" from my email address
                            Jerry Stuckle
                            JDS Computer Training Corp.
                            jstucklex@attgl obal.net
                            =============== ===

                            Comment

                            • Jeff

                              #15
                              Re: help with recusion in DOM

                              Barry wrote:
                              "Jeff" <jeff@spam_me_n ot.comwrote in message
                              news:CaadnfT9W-eCCPrVnZ2dnUVZ_ t_inZ2d@earthli nk.com...
                              >Barry wrote:
                              >>I know this is not a php question. If that bothers you, don't respond. If
                              >>not, I sure could use the advice...
                              >Barry, you should learn something from this.
                              >>
                              >You've asked an OT question without bothering to ask in the group it would
                              >be on topic for. Then you've wasted a lot of time arguing about this. Just
                              >look at the length of the thread.
                              >
                              hey jeff. i actually did ask the question in two javascript newsgroups.
                              after not getting any hits, i asked here. as for my time, i appreciate your
                              consideration thereof.
                              >
                              > BTW, what's with all the inline styles? You could benefit by learning
                              >about CSS descendants, a few classes, and adding a small stylesheet. And,
                              >don't use points.
                              >
                              i'm doing that now. i worked up a static version so i could tweak the
                              appearance and find what the best patterns were to make into the css
                              classes.
                              >
                              btw, what's wrong with points?
                              Historically points are defined by what the OS determines the height of
                              1" is in pixels. PCs settled on 72, Macs on 90 (I believe). So there's
                              quite a size discrepancy if you view on a Mac. That can be particularly
                              bad for small font sizes. Not sure where this issue stands now...

                              Jeff
                              >
                              thanks.
                              >
                              >

                              Comment

                              Working...