提交时,附加值未形成表格

时间:2019-05-16 11:51:42

标签: javascript php jquery append codeigniter-3

public function edit_client_registration_details($c_id,$id)
{
  $data['active_mn']="user_registration_details";
 


  $fileName = $this->input->post('fileName');
  //var_dump($fileName);
  $file = $this->input->post('files');
  //var_dump($file);
  
  if (!empty($fileName)) {
      foreach ($fileName as $key => $name) {
          //$old['fileName'] = $name;
          
          $result[] =  $name;
      }

      $documents = json_encode($result);
      
  }
  
  if (!empty($_FILES['files']['name']['0'])) {
      $old_path_info = $this->input->post('fileName');
      
      $mul_val = $this->do_upload('documents');
      var_dump($mul_val);
      $documents = json_encode($mul_val);
  } 
  
  

  if (!empty($result) && !empty($mul_val)) {
      $file = array_merge($result, $mul_val);
      $documents = json_encode($file);
  }

 
  $data=array(
        'service_name' =>$this->input->post('service_name'),
        'service_number' =>$this->input->post('service_no'),
        'expiry_date' =>$this->input->post('date'),
        'link' =>$this->input->post('link'),
        'documents'=>$documents,
      );
      
 $update=$this->Admin_model->update_service($c_id,$data); 
  if($update)
  {
    $this->session->set_flashdata('success','Reg Details Updated Successfully');
    redirect('admin/add-client-registration-details/'.$id);
  }
  else
  {
    $this->session->set_flashdata('error','Failed');
    redirect('admin/add-client-registration-details/'.$id);
  }    
} 

这是我的代码,在这种情况下,附加的值没有以表格的形式出现,并且这些值没有传递到数据库。我正确地获得了附加视图,但是在该append函数中选择的值是没有得到。 这是我的剧本

var maxAppend = 0;
$(document).on('click', '.update_more', function() {
  var u_id = $(this).attr("u_id");

  var add_new = $('<div class="form-group" style="margin-bottom: 0px">\n\
                    <label for="field-1" class="col-sm-4 control-label">Document</label>\n\
        <div class="col-sm-5">\n\
        <div class="fileinput fileinput-new" data-provides="fileinput">\n\
<span class="btn btn-default btn-file"><span class="fileinput-new" >Select file</span><span class="fileinput-exists" >Change</span><input type="file" name="files[]" ></span> <span class="fileinput-filename"></span><a href="#" class="close fileinput-exists" data-dismiss="fileinput" style="float: none;">&times;</a></div></div>\n\<div class="col-sm-2">\n\<strong>\n\
<a href="javascript:void(0);" class="remCF"><i class="fa fa-times"></i>&nbsp;Remove</a></strong></div>');
  maxAppend++;
  var resil = $(this).closest("#update_new_" + u_id).append(add_new);
  console.log(resil);

});
  <form method="post" class="form_<?php echo $value->id;?>" action="<?php echo base_url();?>admin/edit-client-registration-details/<?= $value->id; ?>/<?= $id; ?>" enctype="multipart/form-data">
<div id="update_new_<?php echo $value->id;?>" class="update_new_<?php echo $value->id;?> item-row">
  <div class="form-group mb0" style="margin-bottom: 0px">
    <label for="field-1" class="col-sm-4 control-label">Other Document</label>
    <div class="col-sm-5">
      <div class="fileinput fileinput-new" data-provides="fileinput">



      </div>
      <div id="msg_pdf" style="color: #e11221"></div>
    </div>
    <div class="col-sm-3">
      <strong>
          <a href="javascript:void(0);" id="update_more" onclick="add_field('<?php echo $value->id;?>');" u_id="<?php echo $value->id;?>" class="addCF item-row-click update_more">
          <i class="fa fa-plus">
          </i>
          &nbsp;Add More</a>
      </strong>
    </div>
  </div>
</div>
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

0 个答案:

没有答案