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

我正在使用带有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">



慕哥6287543
浏览 79回答 1
1回答

守候你守候我

试试这个:$('#edit_depot').val(res[0]['depot_id']).trigger('change');
打开App,查看更多内容
随时随地看视频慕课网APP