[英]I have trouble in set_select in codeigniter
i have worked in a codeigniter framework and i have a problem in select tag. 我曾在codeigniter框架中工作,但在select标签中遇到了问题。 when i want to achieve the value of option that i have selected.
当我想实现我选择的选项的价值时。 i used the method as when i select the option value then i pressed the search button and after what i need the result its showing and then i want to again the value of the selected option with second submit button and the whole data with selected option value must be go to data base.
当我选择选项值时我使用了该方法,然后按了搜索按钮,然后在需要显示结果之后,我想使用第二个提交按钮再次选择所选选项的值,并使用所选选项值再次显示整个数据必须转到数据库。 the code is as follow.
代码如下。
<select id="faculty" data-rel="chosen" name='stdid'>
<option>select student</option>
<?php
foreach ($student as $s) {
echo '<option set_select("student","'.$s['stdid'].'","true") value="'.$s['stdid'].'">'.$s['stdname'].' ' .$s['stdid'].'</option>';
}?>
</select>
You are confusing PHP with HTML. 您将PHP与HTML混淆了。 Change the code to this:
将代码更改为此:
<select id="faculty" data-rel="chosen" name="stdid">
<option>select student</option>
<?php
foreach ($student as $s) {
echo '<option'.set_select("stdid", $s['stdid'], true).' value="'.$s['stdid'].'">'.$s['stdname'].' '.$s['stdid'].'</option>';
}?>
</select>
Note that setting all the option
elements to set_select("stdid", $s['stdid'], true)
will become selected="selected"
. 请注意,将所有
option
元素设置为set_select("stdid", $s['stdid'], true)
将变为selected="selected"
。 Read more about set_select . 阅读有关set_select的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.