我使用select属性使用多个属性来选择多个值,而我正在编辑表单我想从数据库中获取多个值到多个选择标记。
当我正在编辑表单时,我想从数据库中检索值到多个选择框,这些选择框在添加时被选中。
按照我的观点完成的事情
edit_view
<div class="control-group">
<label class="control-label">Assign Task<span class="required">*</span></label>
<div class="controls">
<select data-placeholder="Select Member" class="chosen span6" multiple="multiple" id="assign_task" name="assign_task[]" tabindex="6" data-required="1" placeholder="">
<?php
foreach ($developer_result as $developer) {
?>
<optgroup label="<?php //echo $developer->usertypeid; ?>" >
<option selected="" value="<?php echo $developer->userid; ?>"><?php /*echo $developer->usertitle; echo " ";*/ echo $developer->title; ?></option>
<?php
}
?>
</optgroup> </select><p><?php echo form_error('assign_task'); ?></p> </div></div>
答案 0 :(得分:1)
您正在查看以下代码吗?否则请指定更改
<div class="control-group">
<label class="control-label">Assign Task<span class="required">*</span></label>
<div class="controls">
<select data-placeholder="Select Member" class="chosen span6" multiple="multiple" id="assign_task" name="assign_task[]" tabindex="6" data-required="1" placeholder="">
<option value="">Please choose</option>
<?php
if(!empty($developer_result))
{
foreach ($developer_result as $developer)
{
$dvprid=$developer->userid;
?>
<option value="<?php echo $developer->userid; ?>" <?php if($dvprid==$ind_result->userid) {?>selected="selected"<?php } ?>>
<?php echo echo $developer->title; ?>
</option>
<?php
}
}?>
</select>
这里ind_result是个人数据持有者