-1
Good morning guys, all beauty?
I am making an application where my select will operate what will appear on my page. I am using Codeigniter, so the choice of select goes to a controller. I need my page not refresh!
I’m using Ajax to try to get around this situation, but my first visit to him was yesterday, I’m very lay yet.
What happens is:
I want to take the value of select -> play this value in the controller -> and bring the data of my Query check in db to view.
Html:
<form real="form" id="User" nome="form" method="post" action='<?= base_url("index.php/welcome");?>'>
<select class="form-control" name="selectUser" id="seletor">
<option value='<?= $_SESSION["nome"]?>' >Only me</option>
<option value="" >Team</option>
</select>
</form>
Controller:
public function index()
{
$nome = $this->input->post('selectUser');
echo $nome;
$this->load->model('testemodel');
$verifica= $this->testemodel->verifica($nome);
$data['nomecliente'] = $verifica['nome_cliente'];
$data['horatotal'] = $verifica['hora_total'];
$data['atividade'] = $verifica['nome_atividade'];
$this->load->view('test', $data);
}
Ajax:
(function () {
document.getElementById('seletor').addEventListener('change', function() {
var selectedOption = this.children[this.selectedIndex];
var value = this.value;
$.ajax({
type: "post",
url: "http://localhost/Time/index.php/welcome/index",
data: value,
dataType: 'json',
});
})
})();
I thank you for any north!
Please avoid long discussions in the comments; your talk was moved to the chat
– Maniero