Php 选择“禁用”不会正确传递值
请帮帮我。 我使用Codeigniter 在我看来Php 选择“禁用”不会正确传递值,php,html,codeigniter,Php,Html,Codeigniter,请帮帮我。 我使用Codeigniter 在我看来 '<select name="sender[]" style="width:150px" class="chzn-select" disabled='disabled'> <?php foreach($statments as $statement): ?> <option value="<? echo $statement->id; ?>" <?php echo ($statement-&
'<select name="sender[]" style="width:150px" class="chzn-select" disabled='disabled'>
<?php foreach($statments as $statement): ?>
<option value="<? echo $statement->id; ?>" <?php echo ($statement->id==$pris->sender)?"selected='selected'":""; ?>><?php echo $statement->name; ?>'<?php endforeach; ?>
如果我使用disabled,它会将sender传递为NULL。
如果我删除禁用,它可以正常工作,但我不需要激活选择 禁用的元素不会在POST中发送其值
如果希望传递数据但阻止用户编辑字段,请改用只读
编辑:显然,这不是框的选项。请参阅以获得解决方案
禁用的元素不会在POST中发送其值
如果希望传递数据但阻止用户编辑字段,请改用只读
编辑:显然,这不是框的选项。请参阅以获得解决方案
我想指出,上述答案是迄今为止最好的解决方案
$('select option:not(:selected)').each(function(){ $(this).attr('disabled', 'disabled'); });
原因是,即使它仍然被禁用,该值仍然会毫无错误地传递到数据库。要指出的是,上述答案是迄今为止最好的解决方案
$('select option:not(:selected)').each(function(){ $(this).attr('disabled', 'disabled'); });
原因是,即使它仍然被禁用,该值仍然会无错误地传递到数据库。谢谢。但我是这样解决问题的。可在以下位置找到:$'select option:not:selected'。每个函数{$this.attr'disabled','disabled';};谢谢但我是这样解决问题的。可在以下位置找到:$'select option:not:selected'。每个函数{$this.attr'disabled','disabled';};