2014-07-02 62 views
0

在HTML,这是完全合法的:如何使用多个相同的键值在Codeigniter中创建下拉/选择?

<select name='val'> 
    <option value='0'>Wrong Answer</option> 
    <option value='0'>Also a wrong Answer</option> 
    <option value='1'>Correct Answer</option> 
    <option value='1'>Also a correct Answer</option> 
    <option value='1'>Another correct Answer</option> 
</select> 

如何阵列的外观要传递给form_dropdown(“VAL”,$阵列)的笨在这种情况下? 这可能吗?

+1

这是不可能不延长形式帮手。或者,您可以给它们不同的值并检查控制器中哪些是正确/不正确的,或者从自定义数组格式手动构建选择。 – Jeemusu

回答

0

密钥=>值配对数组作为参数form_dropdown()form_drop的
语法()函数是:

回波form_dropdown( 'name_of_dropdown',$ key_value_pair_array);

这里是我的工作代码: 学生数组,它包含学生ID为关键和学生姓名的价值现在把这个数组form_dropdown()

$student["101"]="student1"; 
$student["102"]="student2"; 
$student["103"]="student3"; 
$student["104"]="student4"; 
$student["105"]="student5"; I 

echo form_dropdown('student',$student); 
+0

这些没有*多个相同的键值*根据我的例子。 –

相关问题