[英]How to create a drop-down /select in Codeigniter with multiple identical key values?
在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>
在这种情况下,数组如何传递给Codeigniter中的form_dropdown('val',$ array)? 这有可能吗?
将key => value配对数组作为form_dropdown()的参数
form_drop()函数的语法为:
回声form_dropdown('name_of_dropdown',$ key_value_pair_array);
这是我的工作代码: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.