Closed Thread
Results 1 to 2 of 2

Thread: Need to Add Default Year

  1. #1
    Tristine is offline Newbie
    Join Date
    Sep 2009
    Posts
    1
    Rep Power
    0

    Need to Add Default Year

    Hi,

    My name is Tristine. I have the existing javascript code with has no default year. I need to set a default year for it. Please look at the code below and advise me how I need to write the default year.

    thanks.

    function setContractList() //Set Contract List dependent upon mrt
    {
    index = 0;
    ii = document.form1.contract_year.selectedIndex;
    year = document.form1.contract_year.options[ii].value;
    obj = document.form1.contract_id;
    obj.options.length = 1; // Set length back to first blank line
    k=1;
    for(j = 0; j < termArray.length; j++)
    {
    if ((effectArray[j] <= year || effectArray[j] == null || effectArray[j] == "") && (termArray[j] >= year || termArray[j] == null || termArray[j] == ""))
    {
    obj.options[k] = new Option(optionTxt[j], optionVal[j], false, false); // no defaults set
    k++;
    }
    }
    if(obj.options.length != 0) obj.options[0].selected = true; // Blank value is default selection
    }

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    cdg10620's Avatar
    cdg10620 is offline Programming Expert
    Join Date
    Jun 2009
    Location
    Texas
    Posts
    387
    Blog Entries
    3
    Rep Power
    12

    Re: Need to Add Default Year

    If you would like to default to the current year then you can just use code similar to this:

    Code:
    <script type="text/javascript">
    
    var d = new Date();
    var curr_date = d.getDate();
    var curr_month = d.getMonth();
    var curr_year = d.getFullYear();
    
    </script>
    -CDG10620
    Software Developer

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. default arguments
    By jackson6612 in forum C and C++
    Replies: 4
    Last Post: 06-01-2011, 04:32 PM
  2. Default None
    By BASHERS33 in forum Database & Database Programming
    Replies: 6
    Last Post: 04-11-2010, 09:52 AM
  3. Default Parameters
    By Althaz in forum C# Programming
    Replies: 3
    Last Post: 11-21-2008, 10:59 AM
  4. Windows default at bootup
    By Wanch in forum Linux/Unix General
    Replies: 2
    Last Post: 02-21-2008, 11:30 PM
  5. Change the default EXE Icon
    By dirkfirst in forum C# Programming
    Replies: 3
    Last Post: 10-03-2006, 04:10 PM

Tags for this Thread

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