»
EnglishFrenchVietnamese

Print - Auto Month - JavaScriptBank.com

Full version: jsB@nk » Time » Auto Month
URL: http://www.javascriptbank.com/auto-month.html

Auto Month © JavaScriptBank.com This pulldown JavaScript menu will automatically adjust the range of months so that the current month is at the top. The remaining months are placed in order after the current month. The JavaScript menu still functions with JavaScript turned-off.

Full version: jsB@nk » Time » Auto Month
URL: http://www.javascriptbank.com/auto-month.html



JavaScript
<script language="javascript">/* Fang | http://www.webdeveloper.com/forum/member.php?u=6060Gil Davis | http://gil.davis.home.att.net/*/function autoMonth() {var dt = new Date();var mo = dt.getMonth();var ary = [];for (var i=0; i<=12; i++)  {ary[i] = document.f1.s1.options[i];}var j = mo;for (i=0; i<12; i++) {document.f1.s1.options[i] = new Option(ary[j].text, ary[j].value);j = (mo + i + 1) % 12;}}// Multiple onload function created by: Simon Willison// http://simon.incutio.com/archive/2004/05/26/addLoadEventfunction addLoadEvent(func) {  var oldonload = window.onload;  if (typeof window.onload != 'function') {    window.onload = func;  } else {    window.onload = function() {      if (oldonload) {        oldonload();      }      func();    }  }}addLoadEvent(function() {  autoMonth();});</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="f1" action="#" style="width: 15%">  <fieldset><legend>Select Month</legend>    <select name="s1">      <option value="0">January      <option value="1">February      <option value="2">March      <option value="3">April      <option value="4">May      <option value="5">June      <option value="6">July      <option value="7">August      <option value="8">September      <option value="9">October      <option value="10">November      <option value="11">December    </select>  </fieldset></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->