donglu9898 2012-02-29 11:47
浏览 27
已采纳

cakephp传递ajax中的下拉值

I have managed to get the ajax function in cakephp which calls when a dropdown is clicked to populate another dropdown. The one area I cannot get is passing in the id value of the first dropdown so I can do a find.

I wish to pass in the company id so I can get the related employees.

Thanks.

View:

<?php
$this->Js->get('#MonthlyReturnCompanyId')->event('change',
$this->Js->request(
    array(
        'controller'=>'MonthlyReturns',
        'action'=>'getemployees',
    ),
    array(
        'update'=>'#test',
        'async' => true,
        'method' => 'post',
        'dataExpression'=>true,
        'data'=> $this->Js->serializeForm(array(
            'isForm' => false,
            'inline' => true
        ))
    )
)
);
?>



        echo $this->Form->input('company_id' , array('empty' => true));
  • 写回答

1条回答 默认 最新

  • dongxiao0449 2012-08-17 10:23
    关注

    simply pass the company_id at the action request same as done in redirects i.e. :

     $this->Js->request(
    array(
        'controller'=>'MonthlyReturns',
        'action'=>'getemployees',$company_id),
    array(
        'update'=>'#test',
        'async' => true,
        'method' => 'post',
        'dataExpression'=>true,
        'data'=> $this->Js->serializeForm(array(
            'isForm' => false,
            'inline' => true
        ))
    )
    )
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接