0
我是CakePHP的新手,问题是我需要创建动态值来下拉框来自mysql的值。以下是我在控制器中使用的代码:动态下拉框更改取决于CakePHP中的数据库
$wires = $this->wire->find('all',array('conditions'=>array('wire_id'=>$wire_id)));
foreach($wires as $key=>$gs) {
$options[$gs['wires']['type_of_wire']] = $gs['wires']['type_of_wire'];
$options1[$gs['wires']['length']] = $gs['wires']['length'];
$options2[$gs['wires']['color']] = $gs['wires']['color'];
}
在CTP
echo $this->Form->input('wire', array('type' => 'select', 'class'=>'dropdn', 'options'=> $options, 'selected'=> $options, 'div'=>false, 'label'=>false,'id'=>'metal'));
echo $this->Form->input('wire', array('type' => 'select', 'class'=>'dropdns', 'options'=> $options1, 'selected'=> $options, 'div'=>false, 'label'=>false,'id'=>'metal'));
echo $this->Form->input('wire', array('type' => 'select', 'class'=>'dropdned', 'options'=> $options1, 'selected'=> $options, 'div'=>false, 'label'=>false,'id'=>'metal'));
在这里,我创建三个下拉框,但问题是,如果我改变下拉线的框中值类型装置其动态地改变它的正确的长度和颜色下拉框的其余部分。
我也尝试过它,但我不能。
这与Cakephp无关。 Jquery最适合这个。 – Costa
@Moshe Katz,是的,我做了它jQuery的功能 – Ram