douquanhui5735 2015-01-27 15:31
浏览 49
已采纳

如何从yii中的jmultiselect2side中选择并显示在新页面中

I'm new to yii and I don't understand the extensions much but I used this extension called jmultiselect2side because I'm trying to make a site where users could reserve stuff like apparatuses in the lab

Anyway, I need a code that would get the Selected Items and then display them in another page for viewing purposes

I haven't put anything in the controller but the name of my controller and model is Apparatus

Here is my view:

    <?php
    $model= Apparatus::model()->findByAttributes(array('ApparatusCode'=>'1'));
    // complete user list to be shown at multiselect order by ApparatusCode
    $Apparatus= Apparatus::model()->findAll(
             array('order' => 'ApparatusCode'));
    ?>
   <center>
    <?php
             $this-  >widget('application.extensions.jmultiselect2side.Jmultiselect2side',array(
                'model'=>$model,
                'attribute'=>'ApparatusName', //selected items
                'labelsx'=>'Available',
                'labeldx'=>'Selected',
                'moveOptions'=>false,
                'autoSort'=>'true',
                'search'=>'Search:',
              'list'=>CHtml::listData(             // available items
                   $Apparatus,
                   'ApparatusCode',
                   'ApparatusName'),

         ));
     ?>

please help as soon as possible :/

  • 写回答

1条回答 默认 最新

  • duandaijian1583 2015-01-27 17:51
    关注

    put all above elements in a form. Set action for the form. Submit the form then the action in which you are handling this submit request, you can write there

    if(isset($_POST))
    {
    foreach($_POST['Apparatus']['ApparatusName'] as $name)
    {
     do what ever you want
    }
    }
    

    $name will represent the each selected item

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'