Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
261 views
in Technique[技术] by (71.8m points)

Getting value of a textbox and transfer to controller(Codeigniter)PHP

I have problem when i transfer value from view to controller. I don't get the value Here's my method

Manifest.php

<?php foreach($voyage_info as $voyage) {  ?>

  <input type="hidden" name="voyage_id" value="<?=$voyage->voyage_id?>">
  <a class="btn btn-primary primary-bg btn-lg  col-md-2 m-3 btn-cus" href="<?php  echo base_url('PortClient/view_voyage/');?>">
  <h3>Voyage - <?=$voyage->voyage_number?></h3> 
  <small>Schedule - <?=$voyage->expected_arrival?> </small>
  </a>
<?php }  ?>

I want to get the value of voyage_id(Code above) in manifest.php(view page) and transfer it to controller. Here's my controller

PortClient.php

public function view_voyage() {
    $this->Auth->authCheck();
    $data = $this->template();
    $voyage_id = $this->session->userdata('voyage_id');

    $data['view_cargo'] = $this->PortManifestModel->view_voyage($voyage_id)->result();
    // your code here
    $this->load->view("port/client/sub_manifest/sub_manifest_1", $data);
}

and i will call it using $this->session->userdata() but it doesnt transfer.

What should I do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to either use a form and access the value on form submit. OR you can use AJAX to post the value and access it like: $this->input->post("voyage_id") instead of using the session


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...