# Navigation

Cara Mengirim Variabel Javascript Dari View Ke Controller Codeigniter

Cara Mengirim Variabel Javascript Dari View Ke Controller Codeigniter

METODE I
Menggunakan Class URI

Dari Controller A

$data["id"] = ("ID NUMBER");
$this->load->view("VIEW_A", $data);

Link di View A

<a href="<?php echo base_url();?>/controller_b/controllerfunction/<?php echo $id;?>">link</a>

Di Controller B

$id = $this->uri->segment(3);


METODE II
Mengirim menggunakan Form

$data["id"] = ("ID NUMBER");
$this->load->view("VIEW A", $data);

Form di View

<form name="myform" id="myform" action="<?php echo base_url();?>/controllerB/controllerfunction/" method="post">
<input type="hidden" name="id" id="id" value="<?php echo $id;?>" />
<input type="submit" value="See more" />
</form>

Atau bisa juga menggunakan Jquery

<a href="javascript;" id="link">See more</a>
$('#link').click(function() {
    $('#myform').submit();
});

YANG LAIN: