Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8372359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:24:39+00:00 2026-06-09T14:24:39+00:00

I have a series of interdependent select lists which work correctly outside CI. When

  • 0

I have a series of interdependent select lists which work correctly outside CI. When I tried to implement it in Codeigniter, I am not coming on as the first selectlist is not populated, either the echoing is not properly code or I dont know what. This question here will refer to just the first select list, that is, you will not see any jquery, because the first gets populated directly from the database without any “function change”.

so here are the modules:

VIEW

<?php echo form_open('control_form/add_all'); ?>
       <label for="f_state">State<span class="red">*</span></label>
        <select id="f_state" name="f_state">
            <option value=""></option>
            <?php

                foreach($result as $row)
                {
                echo '<option value="' . $row->pais_id . '">' . $row->pais_name . '</option>';
                }

            ?>
        </select>

        <label for="f_city">City<span class="red">*</span></label>
        <!--this will be filled based on the tree selection above-->
        <select id="f_city" name="f_city" id="f_city_label"> 
            <option value=""></option>
        </select>

        <label for="f_membername">Member Name<span class="red">*</span></label>
        <input type="text" name="f_membername"/>
<?php echo form_close(); ?> 

CONTROL

public function add_all()
    {

        #Validate entry form information
        $this->load->model('model_form','', TRUE);        
        $this->form_validation->set_rules('f_state', 'State', 'required');
        $this->form_validation->set_rules('f_city', 'City', 'required');
        $this->form_validation->set_rules('f_membername', 'Member Name', 'required');

        $data['city'] = $this->model_form->get_state(); //gets the available groups for the dropdown


        if ($this->form_validation->run() == FALSE)
        {
              $this->load->view('view_form_all', $data); # parece ser que vuelve a meter los mismos datos que tenia la Form
        }
        else
        {
            #Add Member to Database
            $this->model_form->add_all();
            $this->load->view('view_form_success');
        }


    }

MODEL

<?php
class Model_form extends CI_Model
{
      function __construct()
    {
            // Call the Model constructor
            parent::__construct();
    }

    function get_state()
    {
        $query = $this->db->query('SELECT pais_id, pais_name FROM pais');
        return $query->result();
    }


    function add_all()
    {
        $v_state = $this->input->post('f_state');
        $v_membername = $this->input->post('f_membername');

        $data = array(
                'pais_id' => NULL,
                'pais_name' => $v_state

        );

        $this->db->insert('members', $data);
    }



} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:24:40+00:00Added an answer on June 9, 2026 at 2:24 pm

    You are not sending $result to the view, you need something like:

    $data['result'] = ...//get some data
    $this->load->view('view_form_all',$data);
    

    If the list you want to display is the cities list, then you need to change in your view:

    foreach($city as $row)
    {
          echo '<option value="' . $row->pais_id . '">' . $row->pais_name . '</option>';
    }
    

    since in your controller you are doing:

    $data['city'] = $this->model_form->get_state();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a series of editable lists which, on a press of a button
I have a series of checkboxes in codeigniter and need to show the checked
I have a series of delimited files, some of which have some bad data
I have a series of list items which contain data attributes to store information
I have a series of functions which populate a series of drop down boxes.
I need to create a pdf file which will have series of images, where
I have a series of views which, in an editing mode, add UIButtons in
I have a series of workbooks, containing a series of worksheets, in which I
I have a series of functional tests against a web application that correctly run,
I have a series of ASCII flat files coming in from a mainframe to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.