SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question about displaying weeks for the whole year in a drop down list

    Hi..

    I just want to know how can I display Weeks in a drop down list per year.

    Thank you

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    <select id="tst" size="1">
    </select>
    
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function Weeks(year,day,id){
     var srt,ary=[],z0=1,sel=document.getElementById(id),date,months=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
     sel.options.length=0;
     sel.options[0]=new Option('Select Week');
     for (;z0<366+7;z0++){
      srt=new Date(year,0,z0-6,1);
      if (srt.getDay()==day&&srt.getFullYear()<=year){
       date=(day==0?months[srt.getMonth()]:nu(srt.getDate()))+'-'+(day==0?nu(srt.getDate()):months[srt.getMonth()])+'-'+srt.getFullYear()+'\n';
       sel.options[sel.options.length]=new Option(date,date);
      }
     }
     sel.selectedIndex=0;
    }
    
    function nu(nu){
     return nu>9?nu:'0'+nu;
    }
    
    Weeks(2012,1,'tst');
    
    /*]]>*/
    </script>
    </body>
    
    </html>

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what if I want is one dropdown and the option is week 1 - to what week for the whole year and when after select week display the date range between that week.

    Is it possible?how?

    Thank you for your help..


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
  •