我以前的代码是:在申请之前选择
<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>
应用set set后:但语法错误
<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>
答案 0 :(得分:0)
您可以尝试使用以下代码来帮助您
<select name="position_filled_against_id" id="position_filled_against_id">
<option value="">Select</option>
<?php
foreach($position_filled_against as $position_filled)
{
$selected = "";
if($_REQUEST['position_filled_against_id']==$position_filled->position_filled_against_id)
{
$selected = 'selected="selected"';
}
echo '<option value="'.$position_filled->position_filled_against_id.'" '.$selected.' >'.$position_filled->code.'-'.$position_filled->name.'</option>';
}
?>
</select>
答案 1 :(得分:0)
我删除语法错误
<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.'" '.set_select("position_filled_against_id","$position_filled->position_filled_against_id", TRUE).' >'.$position_filled->code.'-'.$position_filled->name.'</option>';
}
?>
</select>