PHP CodeIgniter - 使用foreach下拉列表不显示“已选择”值

I am generating options for my dropdown using

// view.php
foreach ($plants as $row):
    $options[$row->plant_id] = $row->plant_name;
endforeach;

and then lower in the HTML part of view.php

//view.php
$js = 'onChange = "plantDateDelete(\'/size/get_dates_for_plant/\'+this.value);"';
echo form_dropdown('plant_id', $options, 'Select', $js);

The dropdown show options OK, but it does NOT show 'Select' as the "selected"/default value. It shows up with the first option of the array instead.

The HTML source also shows 'Select' in form_dropdown was ignored.

I really need this dropdown to show up with 'Select' as default so as to force the user to activate the onChange function.

Any idea what is going on here or how to solve this issue?

查看全部
douxuanou2787
douxuanou2787
2011/03/01 01:50
  • drop-down-menu
  • codeigniter
  • php
  • forms
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复