我有一个 javascript 下拉列表,它显示所选值和其他值,但所选值在下拉列表中显示 2 次,它应该只显示 1 次。请任何人帮助我解决问题。例如。如果只有 3 个值 2013、2014.2015 并且我选择 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>