Welcome Guest, Not a member yet? Register   Sign In
Help -passing textbox value to controller
#1

[eluser]johnmiller[/eluser]
this is my textbox

Code:
<input type="text" id="txt_fname" name="txt_fname" />

this is my button
Code:
<?php
    $this->load->helper('form');
    echo form_open('blog/do_search',array('fname' => 'txt_fname'));
  ?>
    <input type="submit" name="button" id="button" value="Search" /></form>

in the controller, i wrote

Code:
function do_search()
    {
      $first_name = $this->input->post('fname');
      $this->load->model('search_model');
      $data['search_details'] =  $this->search_model->search($first_name);
      $this->load->view('search_results', $data);
    }

but i am not getting $first_name value in the model. that means, the value is not passing from view to controller.

where i am making mistakes???
can you please help me?
#2

[eluser]Rick Jolly[/eluser]
You are going to slap yourself. You're using different names: "txt_fname" and "fname".
#3

[eluser]johnmiller[/eluser]
i changed it like this

view
Code:
<input type="text" id="txt_fname" name="fname" />

Code:
<?php
    $this->load->helper('form');
    echo form_open('blog/do_search',array('fname' => 'fname'));
  ?>
    <input type="submit" name="button" id="button" value="Search" /></form>

controller
Code:
function do_search()
    {
      $first_name = $this->input->post('fname');
      $this->load->model('search_model');
      $data['search_details'] =  $this->search_model->search($first_name);
      $this->load->view('search_results', $data);
    }

but still it is not working???

any idea???
#4

[eluser]usmc[/eluser]
[quote author="johnmiller" date="1218154870"]i changed it like this

view
Code:
<input type="text" id="txt_fname" name="fname" />

Code:
<?php
    $this->load->helper('form');
    echo form_open('blog/do_search',array('fname' => 'fname'));
  ?>
    <input type="submit" name="button" id="button" value="Search" /></form>

controller
Code:
function do_search()
    {
      $first_name = $this->input->post('fname');
      $this->load->model('search_model');
      $data['search_details'] =  $this->search_model->search($first_name);
      $this->load->view('search_results', $data);
    }

but still it is not working???

any idea???[/quote]

Change the input name to "txt_fname" as well (not just the id);




Theme © iAndrew 2016 - Forum software by © MyBB