我正在尝试创建一个带有下拉列表的html表单.以下是我的代码:
$output[]='<td><select name="qty'.$name.'">'
for($count=1;$count<=$total;$count+=1) {
'<option value="'.$count.'">'.$count.'</option>'
}
'</select>
</td>';
Run Code Online (Sandbox Code Playgroud)
谁能告诉我可能是什么问题?另外如何将默认选择值设置为1?
你错过了分号:
$tmp ='<td><select name="qty'.$name.'">';
for($count=1; $count <= $total; $count+=1) {
$tmp .= '<option value="'.$count.'"';
if($count == 1) {
$tmp .= ' selected="selected"';
}
$tmp .= '>'.$count.'</option>';
}
$tmp .= '</select></td>';
$output[] = $tmp;
Run Code Online (Sandbox Code Playgroud)
更新:添加"将默认值设置为1"
| 归档时间: |
|
| 查看次数: |
14385 次 |
| 最近记录: |