Welcome Guest, Not a member yet? Register   Sign In
how fill select from another select?
#1

[eluser]Asinox[/eluser]
Hi, im new with CI, and i hav some question about it...

i hav a form and this form hav 2 select (categories and subcategories) the subcategories select i need that the values (option) change if i change the categories and then ill select the subcategories from categories...

And the another question is, the select categories i filled with a funcion that make query and bring me all categories, but when i want to insert the data i hav problem because i hav to function calling the same view (i dont know how use 2 function in the same view), i hav 1 function for fill the categories select and another for save the POST data....but the data can't save...

somebody help me please?

Thanks u
#2

[eluser]Clooner[/eluser]
Quote:i hav a form and this form hav 2 select (categories and subcategories) the subcategories select i need that the values (option) change if i change the categories and then ill select the subcategories from categories…
You probably would need javascript or ajax for this. Check out the videotutorials.

Quote:And the another question is, the select categories i filled with a funcion that make query and bring me all categories, but when i want to insert the data i hav problem because i hav to function calling the same view (i dont know how use 2 function in the same view), i hav 1 function for fill the categories select and another for save the POST data....but the data can’t save…
Do you have a code example?
#3

[eluser]Asinox[/eluser]
Here my controller, im tryin to programming a news paper, function leer (read)article, function nuevo_articulo (new_article) for add new article and here i have the select categories table for fill the select....
Code:
class Periodico extends Controller{
        function Periodico(){ // constructor
            parent::Controller();
            $this->load->helper('url');
            $this->load->helper('form');
        }
        
        function index(){ //index lo mismo que decir index.php
            $data['titulo_site'] = "Paso a Paso Online | Bienvenido";
            $data['query'] = $this->db->get('articles');
            $this->load->view('articulos/articulos_view',$data);
        }
        
        function leer($id = null){
            /*$data['titulo_site'] = "Paso a Paso Online | Bienvenido";
            $data['query'] = $this->db->get('articles');
            $this->load->view('articulos/articulos_view',$data);*/
        }
        
        function nuevo_articulo(){
            $data['titulo_site'] = "Paso a Paso Online | Bienvenido";
            $data['encabezado']= "Agregar Articulos";
            $data['query'] = $this->db->get('categories');  // here for SELECT categories
            $this->load->view('articulos/agregar_view',$data);
            
            if(isset($_POST['submit'])){
                $this->db->inset('articles',$_POST);
                //redirect('index');
            }            
        }
        
    
}

Where r the videostutorials? just i found blog video tutorial

Thanks
#4

[eluser]Bramme[/eluser]
Have a look here
http://ellislab.com/forums/viewthread/82447/

Wink




Theme © iAndrew 2016 - Forum software by © MyBB