【发布时间】:2018-01-25 06:18:54
【问题描述】:
我正在这样做。这是我从数据库结果中填充的动态下拉列表。当我提交表单时,应用验证,如果在空字段上发生验证错误,表单将停止提交。但是所有下拉菜单也会删除它的值,所以我再次填写所有表单而不是空白字段
我之前的代码是:apply set select之前
<select name="position_filled_against_id" id="position_filled_against_id">
<option value="">Select</option>
<?php
foreach($position_filled_against as $position_filled)
{
$selected = "";
echo '<option value="'.$position_filled->position_filled_against_id.'" >'.$position_filled->code.'-'.$position_filled->name.'</option>';
}
?>
</select>
应用集选择后:但语法错误
<select name="position_filled_against_id" id="position_filled_against_id"><option value="">Select</option>
<?php
foreach($position_filled_against as $position_filled)
{
$selected = "";
echo '<option value="'.set_select("position_filled_against_id",$position_filled->position_filled_against_id,TRUE).'" >'.$position_filled->code.'-'.$position_filled->name.'</option>';
}
?>
</select>
【问题讨论】:
-
它只给出语法错误。我想在验证应用后设置下拉列表的值
-
但没有显示错误
-
您需要您的建议,您是否愿意对我的代码做同样的事情,因为我有语法错误
标签: php codeigniter