[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]
[Particle description]
Copy the codeThe code is as follows:
var dateSelector = new DateSelector(year pull-down ID, month pull-down ID, day pull-down ID, {floorYear: forward years, ceilYear: backward years});
= = function(){ // Customize the start-end event
$('info').innerHTML = () + 'year' +
('0' + ()).slice(-2) + 'month' +
('0' + ()).slice(-2) + 'day';
}
(); // Initialization begins
[Explanation text]
The method to generate option here selects the regular options[i].text = options[i].value = i;
I used this method during this period:
[] = new Option(i, i, false, (i == sign ? true : false))
This new Option has 4 parameters available (text, value, defaultSelected, selected); the last parameter can be set and selected.
But no official information was found. I also encountered a bug in IE6. Please correct me if you have used it.
BUG Demo
This is fine in IE7, IE8, FF3, etc. But in IE6, the previous one will be selected. The reason is unknown yet. (It seems to be a problem with IE Tester after confirmation. Then the following solution is also a simple generation option)
Test code:
Copy the codeThe code is as follows:
<select ></select>
<script type="text/javascript">
<!--
var osel = ('year');
var sign = 2008;
for(var i = 2001; i < 2010; i++) {
[] = new Option(i, i, false, (i == sign ? true : false));
}
//-->
</script>