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 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件