为了账号安全,请及时绑定邮箱和手机立即绑定

如何以形式显示逗号分隔的值

如何以形式显示逗号分隔的值

PHP
慕哥6287543 2022-08-19 15:30:38
我正在使用带有javascript和ajax的协调员php框架。逗号分隔的值不显示,但单个值工作正常。我有表字段,如(edit_coach = 9,10,11),(edit_depot = 5,Spur,SPJ)和edit_task_type = 5请分享有价值的想法...数据库edit_coach = 9,10,11 //not show data edit_depot = 5,Spur,SPJ //not show data edit_task_type = 5 //working fine JavaScript Code here function edit_assign_train(val)        {            $.ajax({            url: "<?php echo base_url(); ?>edit_assign_train",            type: "post",            data: "atrain_id="+val,            success: function (response)            {                var res = JSON.parse(response);                console.log(res);                 $('#edit_train_no').val(res[0]['train_no']);             $('#edit_depot').val(res[0]['depot_id']+'-'+res[0]['depot_code']+'-'+res[0]['depot_name']).trigger('change');// not working            $('#edit_coach').val(res[0]['coach']).trigger('change');// not working             $('#edit_task_type').val(res[0]['task_type']).trigger('change');//working fine             $('#edit_tot_coach').val(res[0]['tot_coach']);            $('#edit_janitor').val(res[0]['janitor']);            $('#edit_time').val(res[0]['time_val']);            $('#edit_id').val(res[0]['id']);            }        });此处的 HTML 代码<div class="row">                    <label class="col-sm-4 col-form-label text-right">Depot : </label>                    <div class="col-sm-8">                    <div class="form-group">
查看完整描述

1 回答

?
守候你守候我

TA贡献1802条经验 获得超10个赞

试试这个:

$('#edit_depot').val(res[0]['depot_id']).trigger('change');


查看完整回答
反对 回复 2022-08-19
  • 1 回答
  • 0 关注
  • 75 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信