Results 1 to 2 of 2

Thread: Dates in form fields

  1. #1
    Join Date
    Sep 2004
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Dates in form fields

    Is there a script i can use to do the following

    I have 4 text fields each with different dates in and a drop down select menu with numbers from 1 to 28.

    If the user selects 10 from the drop down (months) it automatically changes the dates in the four text fields (date1,date2 etc) to add 10 months to the date that was already in there.

    <select name="months" style="width: 100px;">
    <option selected="selected" value="18">-- 18 (default) -</option>
    <option value="0">-- select --</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    .....etc

    <input name="date1" id="date1" type="text" tabindex="12" value="20/01/2009" />
    <input name="date2" id="date2" type="text" tabindex="12" value="20/03/2009" />
    <input name="date3" id="date3" type="text" tabindex="12" value="20/06/2009" />
    <input name="date4" id="date4" type="text" tabindex="12" value="20/09/2009" />

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    This page has a useful feature that adds months to a date, it also adjusts for the end of a month.

    http://lawrence.ecorp.net/inet/samples/js-date-fx.shtml

    It should be possible to incorporate this into a function that updates the dates in the 4 text boxes using this type of javascript syntax:

    Code:
    document.getElementById('field1').innerHTML = newdate1;
    document.getElementById('field1').value = newdate1;
    document.getElementById('field2').innerHTML = newdate2;
    document.getElementById('field2').value = newdate2;

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
  •