【发布时间】:2013-11-15 10:54:55
【问题描述】:
我需要按钮上的“onclick”操作,所以我会被重定向到这样的事情:
location/[textfield_data]
我正在使用 cakephp,此时我到达的最近的是这个。
echo $this->Form->input('link', array('label' => false, "class" => "form-control input-medium", "placeholder" => __('Procurar')));
echo $this->Form->button('', array('class' => 'btn btn-primary icon-search icon-white' ,'onclick' => "location.href='/'"));
使用我的代码,cakephp 正在检索我:
/[view]?data%5Blink%5D=
[view] 是我所在的当前页面。
找到解决方案
我已经通过这种方式找到了解决方案。
echo $this->Form->input('link', array('label' => false, "class" => " form-control input-medium", "placeholder" => __('Procurar'), 'id' => 'search'));
echo $this->Form->button(null, array('class' => 'btn btn-primary icon-search icon-white' ,'onclick' => "location.href='/mywantedurl/'+document.getElementById('search').value;"));
请注意,我没有使用任何表单->创建或表单->结束,否则将无法正常工作。
【问题讨论】:
标签: php forms cakephp search redirect