当前页面
代码
$body .= 'select name="number" id="';
$body .= $row["ID"] . '" onchange="changeNumber( this );" >';
//
$qty = (int) $row["quantity"];
for ($number = 0; $number <= 10; $number++) {
$body .= '<option ';
if ($number == $qty) {
$body .= ' selected value="' . $number . '">' . $number . '</option>';
} else {
$body .= ' value="' . $number . '">' . $number . '</option>';
}
}
$body .= /select>';
答案 0 :(得分:-1)
尝试
$body .= '<select name="number" id="'.$row["ID"] .'" onchange="changeNumber( this );" >';
$qty = (int) $row["quantity"];
for ($number = 0; $number <= 10; $number++) {
$selected = '';
if($number == $qty) {
$selected = "selected";
}
$body .= '<option '.$selected.' value="' . $number . '">' . $number . '</option>';
}
$body .= '</select>';