0
在下面的代碼中,首先我已經使用javascript代碼的下拉列表,當我更新只有第一行得到更新,剩下的不更新。並在接下來的我使用的HTML代碼,它得到所有行更新任何人都可以幫助解決這個問題。我從html更改爲js的原因是汽車年。在下拉列表中的javascript值沒有更新
<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++;
if (date != <?php echo $row->year; ?>) {
document.write ("<option value=\"" +date+"\">" +date+ "");
}
}
while (date < future);
document.write ("</select></form>");
}
</script>
<script type="text/javascript">
autoYear();
</script>
的Html
<select class="inputmedium" name="year_<?php echo $row->id; ?>" id="year_<?php echo $row->id; ?>" value="<?php echo $row->year; ?>">
<?php for($s=0;$s<8;$s++)
{
if($row->year!=null and $row->year==$year_array[$s]){
echo "<option selected value='" .$year_array[$s]. "'>" .$year_array[$s]. "</option>";
}else{
echo "<option value='" .$year_array[$s]. "'>" .$year_array[$s]. "</option>";
}
} ?>
</select>
<?php
$year_array=array();
$year_array[0]="2013";
$year_array[1]="2014";
$year_array[2]="2015";
$year_array[3]="2016";
$year_array[4]="2017";
$year_array[5]="2018";
$year_array[6]="2019";
$year_array[7]="2020";
?>
的問題並沒有解決只有第一行被更新剩餘行不 – user2935177