Results 1 to 4 of 4

Thread: JS Calendar Script Help

  1. #1
    Join Date
    May 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JS Calendar Script Help

    script: http://www.dynamicdrive.com/dynamici...oncalendar.htm

    I've been really pleased with this script except for one small issue, and I have to say I am not familiar enough with javascript to trace it.
    When a user enters their "year" into the year field (ie types it in) it doesn't register in the script unless they press enter or unless they use the calendar object.

    Is it possible to alter the script in anyway to either grey out the year box and force the user to select the calendar object or, preferably, for the script to take the year when the the year field loses focus?

    Thanks in advance
    Kia

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm no sure I understand. On the demo page if I click this button:

    Code:
    <input type="button" onClick="alert(this.form.orderdate.value)" value="Show date value passed">
    which clicking on is not hitting 'enter', the value I typed into the year field is shown. I guess I'm a little vague on what you mean by 'use the calendar object'. I can do this in the address bar:

    Code:
    javascript:alert(document.forms[3][3].value)
    and it accurately reports any typed in change to the value of the second year field on the page. ([1][3] will get the first one) Just exactly what isn't this doing for you?

    Please post a link to the page on your site that contains the problematic script so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    http://www.kia-tickers.com/preg/ticker.html

    As an example if someone has a due date of January 28th 2007
    they select January and the day (28) from the drop down boxes.
    then if they type 2007 in the text box (next to the calendar object) but they don't press enter after typing in 2007, and if they don't use the calendar object then the script still takes the year variable as being 2006.

    this is evidenced in the html coding provided on the result page

    I believe I need to add an "onLostFocus" statement but I'm not 100% sure as to what it should say or where I should place it.
    Last edited by Kia; 05-17-2006 at 07:23 PM.

  4. #4
    Join Date
    May 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    [SOLVED]

    I added this:
    Code:
    onChange="' + DateName + '_Object.fixYear(this)"
    to this:
    Code:
    writeln('<input' + InitialStatus + ' class="calendarDateInput" type="text" id="' + DateName + '_Year_ID" size="' + eval(DateName + '_Object.picked.yearPad.length') + '" maxlength="' + eval(DateName + '_Object.picked.yearPad.length') + '" title="Year" value="' + eval(DateName + '_Object.picked.yearPad') + '" onKeyPress="return YearDigitsOnly(window.event)" onKeyUp="' + DateName + '_Object.checkYear(this)" onBlur="' + DateName + '_Object.fixYear(this)">');

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
  •