Welcome Guest, Not a member yet? Register   Sign In
Pass button id to controller from view
#1

Hey guys can i pass my button id to controller?

I need this to make a select in Model.


View button code. 
Code:
<button class="btn btn-primary" data-book-id="<?php echo $historico->codigo ?>" data-target="#form-modal" data-toggle="modal">Visualizar</button>
Reply
#2

(This post was last modified: 08-17-2015, 06:48 PM by pdthinh.)

(08-17-2015, 05:37 PM)nofpowells Wrote: Hey guys can i pass my button id to controller?

I need this to make a select in Model.


View button code. 




Code:
<button class="btn btn-primary" data-book-id="<?php echo $historico->codigo ?>" data-target="#form-modal" data-toggle="modal">Visualizar</button>

You can set the value attribute of the button

Code:
<button class="btn btn-primary" name="button_name" value="<?php echo $id_to_set ?>" data-book-id="<?php echo $historico->codigo ?>" data-target="#form-modal" data-toggle="modal">Visualizar</button>
In the controller, you can get the set value like this

PHP Code:
$id $this->input->post('button_name'); 
Reply
#3

(08-17-2015, 06:46 PM)pdthinh Wrote:
(08-17-2015, 05:37 PM)nofpowells Wrote: Hey guys can i pass my button id to controller?

I need this to make a select in Model.


View button code. 






Code:
<button class="btn btn-primary" data-book-id="<?php echo $historico->codigo ?>" data-target="#form-modal" data-toggle="modal">Visualizar</button>

You can set the value attribute of the button



Code:
<button class="btn btn-primary" name="button_name" value="<?php echo $id_to_set ?>" data-book-id="<?php echo $historico->codigo ?>" data-target="#form-modal" data-toggle="modal">Visualizar</button>
In the controller, you can get the set value like this



PHP Code:
$id $this->input->post('button_name'); 

i'm trying but not work

 my Controller 

PHP Code:
public function historicochamada(){       
        
        $cod 
$this->input->post('vizualizar');
 
               
        $this
->load->model("historico_model","Home");
 
       $dados= array(
 
           "historicos" => $this->Home->listar(),
 
           "participantes" => $this->Home->listarParticipantes($cod)
 
       );
 
       
        
        
        $this
->load->view('layout/topo');
        
$this->load->view('layout/menu');
 
       $this->load->view('cliente/historico_chamadas'$dados);
        
$this->load->view('layout/rodape');

    } 
Reply
#4

Well, to complete my question.

This button open a modal i the same page.
How can i call a function in controller using a button?
Reply
#5

(08-17-2015, 07:58 PM)nofpowells Wrote: Well, to complete my question.

This button open a modal i the same page.
How can i call a function in controller using a button?

It looks like you're opening a modal use javascript / jquery, so you should reference the modal docs.
If you want to pass it to a controller (on server side), make sure you put the button on a form.

P/s: Sorry for my English
Reply
#6

(08-17-2015, 10:34 PM)pdthinh Wrote:
(08-17-2015, 07:58 PM)nofpowells Wrote: Well, to complete my question.

This button open a modal i the same page.
How can i call a function in controller using a button?

It looks like you're opening a modal use javascript / jquery, so you should reference the modal docs.
If you want to pass it to a controller (on server side), make sure you put the button on a form.

P/s: Sorry for my English
Yeah, its a modal. I'm researching, but maybe only with Ajax to populate modal.

Where you from?
Reply
#7

(08-17-2015, 11:24 PM)nofpowells Wrote:
(08-17-2015, 10:34 PM)pdthinh Wrote:
(08-17-2015, 07:58 PM)nofpowells Wrote: Well, to complete my question.

This button open a modal i the same page.
How can i call a function in controller using a button?

It looks like you're opening a modal use javascript / jquery, so you should reference the modal docs.
If you want to pass it to a controller (on server side), make sure you put the button on a form.

P/s: Sorry for my English
Yeah, its a modal. I'm researching, but maybe only with Ajax to populate modal.

Where you from?
I'm from Vietnam.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB