【问题标题】:pass the button value from view to controller(codeigniter)将按钮值从视图传递给控制器​​(codeigniter)
【发布时间】:2021-11-17 08:39:35
【问题描述】:

您好,我在传递按钮值时遇到问题... 当我单击按钮时,我想显示详细信息取决于按钮 但我猜按钮值不会从视图传递到控制器。帮助,,,


//view(button)

<div class="marketer">
<?php foreach($marketer_list as $marketer){ ?>
<button  type="button"  class="mid" name= "posting_user_id" value="<?=$marketer->id?>"><?=$marketer->username?></button>
<?php }?> 
</div>
 

  $(document).ready(function () {
 
$('.mid').click(function(){
    var id = $(this).attr('value');
  alert(id);
    if (id=='<?=$detail->posting_user_id?>')
    {
      $(".show_posting").show(); 
    }else{
            alert("no info");
    }
  });
}); 
 
 
 
//controller
$posting_user_id = $this->input->post('posting_user_id');
 
 
  $data['daily'] = $result;
  $data['posting'] = $this->posting_models->get_manage_hospital_list($posting_user_id);
   $this->load->view('posting',$data);
 
//model
  function get_manage_hospital_list($posting_user_id){
    $this->db->select('u.hosp_name,p.*');
    $this->db->from('users as u');
    $this->db->join('posting_plan as p', 'u.id=p.hospital_id');
    $this->db->where('posting_user_id',$posting_user_id);
    $this->db->order_by('p.report_day','asc');
   
    return $this->db->get()->result();
  }

【问题讨论】:

  • 您想要显示特定按钮点击 ID 的完整详细信息。
  • 在链接stackoverflow.com/questions/65229377/…上查看我的答案
  • 您是否尝试过为该按钮添加名称并将标签名称从按钮更改为输入?

标签: javascript php jquery codeigniter


【解决方案1】:

您还没有为具有名为“mid”的类的按钮添加 id。 不要忘记在那里放一个唯一的ID。您还必须检查 $detail->posting_user_id 在视图中是否有值。

【讨论】:

    猜你喜欢
    • 2018-01-17
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多