Question: How to send cant send the information from a select to the controller.

I want to do a search with a filter of categories using a select to filter. The data of the select comes from a BD. The data of the select is the id and name.

It should work that when you look for something and you want to filter by category to the select, once select the category in the select automatically redirect you to the same view but loading another model with another query

Code view:

```
<?php echo form_open('Welcome/myfunction'); ?>
    <select name="category">
      <option value="">filter</option>
      <?php
      foreach ($cat -> result() as $row){ 
        echo "<option value'".$row->id."'>".$row->name."</option>";
      }
      ?>
    </select>
<?php form_close(); ?>

```

Code Controller:

```
public function myFunction(){
     $b = $this->input->post('category');
     echo $b;
}

```

It's a simple function to know if view and controller works. With this code i select the category in the select but it doesn't do nothing.

Answer: 
Aside from what @PawelSzalucki pointed out, your `option` value is not properly set

Take a look here

```
<?php
   foreach ($cat -> result() as $row){ 
   echo "<option value'".$row->id."'>".$row->name."</option>"; //here
 }
?>

```

It should be

```
echo "<option value='".$row->id."'>".$row->name."</option>"; // value=

```
You can use `onchange` method on `<select>` and `ajax` call to pass value to "myFunction" 

```
<?php echo form_open('Welcome/myfunction'); ?>
<select name="category" id="yourid">
  <option value="0">filter</option>
  <?php
  foreach ($cat -> result() as $row){ 
    echo "<option value='".$row->id."'>".$row->name."</option>";
  }
  ?>
</select>

```

Code view -> add ajax:

```
<script>
$('#yourid').change(function() {
    var categid      = $(this).val();
    var categval    = $(this). text();
    $.ajax({
            url: 'http://domain/myFunction', //where you need to call ajax
            type: 'POST',
            dataType: 'JSON',
            data: {'category': categval, ‘catid’: categid}, //value of x with param 
            success: function (data) {
                console.log(data);
                 //check and print console value   
            },
            error: function (e) {
                //called when there is an error
                console.log(e.message);
            }
        });

}
</script>

```

Code Controller:

```
public function myFunction(){
    $b = $this->input->post('category');
    echo $b;
    //check post print_r(chck posted value here);

  }

```

Good luck :)