douai2499 2014-11-11 17:32 采纳率: 100%
浏览 91
已采纳

从x可编辑的php中获取选择选项

I am using x editable for inline editing.

JQUERY

$('#status').editable({
  value: 2,
  source: [
  {value: 1, text: 'Active'},
  {value: 2, text: 'Blocked'},
  {value: 3, text: 'Deleted'}
  ]
});

This one is running fine. But the problem is, I want to get source options from php. For that I have an array.

PHP

$php_array = Array ( [MOBILE_TOPUP] => MOBILE_TOPUP
                     [PICKUP] =>PICKUP
                     [DELIVERY] => DELIVERY
                     [BANK_DEPOSIT] => BANK_DEPOSIT )

I tried with by passing below variable in source but it's not working:

var json_array = <?=json_encode($php_array)?>;

How can I achieve this? Do I need to change array structure in PHP? Thanks for any help!

  • 写回答

2条回答 默认 最新

  • dongxianrang9269 2014-11-11 17:51
    关注

    Yes, you have to change array structure as below :

    $php_array = Array ( 
            array('value' => 1, 'text' => 'Active'),
            array('value' => 2, 'text' => 'Blocked'),
            array('value' => 3, 'text' => 'Deleted'),
    );
    
    var json_array = '<?=json_encode($php_array)?>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 前端 uniapp App端在离线状态如何使用modbus 连接手机蓝牙进行读写操控机器?
  • ¥15 SQL语句根据字段自动生成行
  • ¥500 “掌声响起来”软件(不确定性人工智能)
  • ¥500 我要找大模型一体机产品手册和应用案例
  • ¥60 用r语言进行数据分析
  • ¥20 关于游戏c++语言代码问题
  • ¥15 如何制作永久二维码,最好是微信也可以扫开的。(相关搜索:管理系统)
  • ¥15 delphi indy cookie 有效期
  • ¥15 labelme打不开怎么办
  • ¥35 按照图片上的两个任务要求,用keil5写出运行代码,并在proteus上仿真成功,🙏