使用Codeigniter在菜单下拉菜单中设置选定的选项 [英] Set a selected option in menu dropdown with codeigniter

查看:136
本文介绍了使用Codeigniter在菜单下拉菜单中设置选定的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我选择使用标签而不是Form Helper中的form_dropdown(),因为我无法将属性归类到<option>标签. 所以我有一个<select>并想将项目设置为"selected".此数据来自数据库.我该如何设置? 我看到了:set_select(),但是我无法工作. 有人有解决方案吗?

I chose to use tag instead of form_dropdown() from Form Helper because i can't set a class atribute to <option> tag. So I have a <select> and want to set a item with as "selected". This data is coming from database. How I set this? I saw this: set_select() but I can't make work. Does anyone have a solution?

推荐答案

文档上form_dropdown功能:

form_dropdown()

form_dropdown()

让您创建一个标准的下拉字段.第一个参数将包含字段名称,第二个参数将包含选项的关联数组,并且第三个参数将包含您希望选择的值.

Lets you create a standard drop-down field. The first parameter will contain the name of the field, the second parameter will contain an associative array of options, and the third parameter will contain the value you wish to be selected.

echo form_dropdown('shirts', $options, 'large'); // 'large' will be "selected"

这篇关于使用Codeigniter在菜单下拉菜单中设置选定的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆