我有一个带有选择输入的表单。我想在选择下拉列表时自动提交表单。
我的代码:
<?php echo $this->Form->create('Product', array('controller'=>'products', 'action'=>'shipping_area'));
echo $this->Form->input('area', array('options' => array('1' => 'Within Malaysia', '2' => 'International'), 'empty' => 'choose area',
'label' => 'Choose shipping area', 'onChange'=>'javascript:this.form.submit()'));
//echo $this->Form->end('Save');
?>
I put 'onChange'=>'javascript:this.form.submit()', but it goes to http://localhost/cake/cake/products/shipping_area ( supposely http://localhost/cake/products/shipping_area )
我也尝试了'onChange'=〉' this.form.submit()',但是得到了同样的错误。
谁能帮帮忙。
2条答案
按热度按时间holgip5t1#
您可以在表单中添加一个“id”属性,然后每次在“select”元素中获得“onchange”事件时,您都必须获取“id”值并将其传递给javascript函数“document.getElement('idValueHere ')”,然后调用函数submit。更清楚地说,下面的代码:
bejyjqdl2#
希望对你有帮助。