選択した値と他の値を表示するjavascriptドロップダウンがありますが、選択した値はドロップダウンに2回表示され、1回だけ表示されるはずです。2013、2014.2015 の 3 つの値しかなく、2013 を選択した場合、2013- 選択された値が表示されます 2013 2013 2014 2015
<script type="text/javascript">
function autoYear() {
var time = new Date();
var year = time.getYear();
if (year < 1900) {
year = year + 1900;
}
var date = year - 1; /*change the '25' to the number of years in the past you want to show */
var future = year + 10; /*change the '10' to the number of years in the future you want to show */
document.writeln ("<form><select id='year_<?php echo $row->id ?>' name='year_<?php echo $row->id ?>' ><option value=\"\"><?php echo $row->year; ?>");
do {
date++;
document.write ("<option value=\"" +date+"\">" +date+ "");
}
while (date < future)
document.write ("</select></form>");
}
</script>
<script type="text/javascript">
autoYear();
</script>