简体   繁体   English

如何在Codeigniter中创建具有多个相同键值的下拉/ select?

[英]How to create a drop-down /select in Codeigniter with multiple identical key values?

In HTML this is perfectly legal: 在HTML中,这是完全合法的:

 <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>

How does the array look to be passed to form_dropdown('val',$array) in Codeigniter in this case? 在这种情况下,数组如何传递给Codeigniter中的form_dropdown('val',$ array)? Is this possible at all? 这有可能吗?

Give key=>value paired array as parameter to form_dropdown() key => value配对数组作为form_dropdown()的参数
syntax of form_drop() function is: form_drop()函数的语法为:

echo form_dropdown('name_of_dropdown',$key_value_pair_array); 回声form_dropdown('name_of_dropdown',$ key_value_pair_array);

here is my Working code: student is array which contains student ID as key and student name as value now pass this array to form_dropdown() 这是我的工作代码:student是一个数组,其中包含学生ID作为键,而学生姓名作为值,现在将此数组传递给form_dropdown()

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

echo form_dropdown('student',$student);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM