Formda ayı ve yılı otomatik seçsin (varsayılan olarak)
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Fang | http://www.webdeveloper.com/forum/member.php?u=6060 */
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] = ary[j];
j = (mo + i) % 12;
}
document.f1.s1.options[0].selected=true;
}
// Multiple onload function created by: Simon Willison
// http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function 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();
});
Head
<script type="text/javascript" src="autoMonth.js"></script>
Body
<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>