0
Good morning Galerinha, everything beautiful?
I’m starting with the codeigniter
and in the middle of that process I came across a question about the function select
. Well, my question is to return the value
from that select to mine controller
, so I can do a check from the value
.
I have a chart and I need to control his information by mine select
.
As if my select
become a button
, then when I chose the option automatically the chart information would change.
select{
-webkit-appearance: none !important;
-webkit-border-radius: 0px;
background-color: #fafafa;
background-position: 100% center;
background-repeat: no-repeat;
border: 1px solid #cccccc;
padding: 0.5rem;
font-size: 0.875rem;
color: rgba(0, 0, 0, 0.75);
line-height: normal;
border-radius: 0;
height: 2.3125rem;
border-radius: 1px rgb(189, 189, 189) !important;
min-width: 20px !important;
}
<select class="form-control" id="menuselect">
<option>Only me</option>
<option>Team</option>
</select>
Okay, only that’s my question, how do I get it in the controller? $this->input->post() ? or set_select()?
– Diêgo Correia de Andrade
look php is not my specialty but tries the following command, $selectOption = $_POST['menuselect'];
– DFernandes
I’m by the codeigniter, I made the call, but it doesn’t work, I think I should turn my select into a "button" like the form action.
– Diêgo Correia de Andrade
I gave a search to have help here, people say to use this command $variavel = $this->input->post("menuselect");, in case you need to make sure that the select is inside a form with http method being post
– DFernandes
I did it here, but my value isn’t being captured. was like this Html: <form name="selectUser" id="selectUser" method="post" action="Welcome/client"> <select class="form-control" onchange="Document.getElementById('selectUser'). Submit()" > <option value='<? php$_SESSION["name"]? >'>Only me</option> <option value="Diego">Team</option> </select> </form> my controller insert like this: $name = $this->input_post('selectUser'); echo $name; .
– Diêgo Correia de Andrade
Got it! I forgot to declare name="selectUser" in my <select>! Thanks for helping!
– Diêgo Correia de Andrade
I believe you are not taking it because you did not give a reference id to select, what should be coming to the controller is an empty request, try to put a name in select and give a name to it and in the controller try to capture the name of select not the id, name of the form, just for tbm, make a simple test, in onchange put an Alert and pass the value of select to see what it returns
– DFernandes
perfect! I’m happy to help
– DFernandes