├── LICENSE ├── system ├── .htaccess ├── fonts │ ├── texb.ttf │ └── index.html ├── index.html ├── core │ ├── index.html │ ├── Model.php │ ├── Controller.php │ ├── Benchmark.php │ ├── Utf8.php │ ├── Lang.php │ └── Exceptions.php ├── database │ ├── index.html │ ├── drivers │ │ ├── index.html │ │ ├── pdo │ │ │ ├── index.html │ │ │ ├── pdo_utility.php │ │ │ └── pdo_result.php │ │ ├── cubrid │ │ │ ├── index.html │ │ │ ├── cubrid_utility.php │ │ │ └── cubrid_result.php │ │ ├── mssql │ │ │ ├── index.html │ │ │ ├── mssql_utility.php │ │ │ └── mssql_result.php │ │ ├── mysql │ │ │ ├── index.html │ │ │ ├── mysql_result.php │ │ │ └── mysql_utility.php │ │ ├── mysqli │ │ │ ├── index.html │ │ │ ├── mysqli_utility.php │ │ │ └── mysqli_result.php │ │ ├── oci8 │ │ │ ├── index.html │ │ │ ├── oci8_utility.php │ │ │ └── oci8_result.php │ │ ├── odbc │ │ │ ├── index.html │ │ │ └── odbc_utility.php │ │ ├── postgre │ │ │ ├── index.html │ │ │ ├── postgre_utility.php │ │ │ └── postgre_result.php │ │ ├── sqlite │ │ │ ├── index.html │ │ │ ├── sqlite_utility.php │ │ │ └── sqlite_result.php │ │ └── sqlsrv │ │ │ ├── index.html │ │ │ ├── sqlsrv_utility.php │ │ │ └── sqlsrv_result.php │ ├── DB.php │ └── DB_cache.php ├── helpers │ ├── index.html │ ├── language_helper.php │ ├── email_helper.php │ ├── path_helper.php │ ├── xml_helper.php │ ├── number_helper.php │ ├── directory_helper.php │ ├── typography_helper.php │ ├── cookie_helper.php │ ├── array_helper.php │ ├── download_helper.php │ └── security_helper.php ├── language │ ├── index.html │ └── english │ │ ├── index.html │ │ ├── number_lang.php │ │ ├── migration_lang.php │ │ ├── unit_test_lang.php │ │ ├── profiler_lang.php │ │ ├── ftp_lang.php │ │ ├── calendar_lang.php │ │ ├── upload_lang.php │ │ ├── email_lang.php │ │ ├── form_validation_lang.php │ │ ├── imglib_lang.php │ │ ├── db_lang.php │ │ └── date_lang.php └── libraries │ ├── index.html │ ├── Log.php │ ├── Cache │ └── drivers │ │ ├── Cache_dummy.php │ │ ├── Cache_apc.php │ │ └── Cache_file.php │ └── Parser.php ├── application ├── .htaccess ├── views │ ├── html │ │ ├── footer.php │ │ └── header.php │ ├── index.html │ └── dropdown │ │ └── index.php ├── index.html ├── core │ └── index.html ├── hooks │ └── index.html ├── logs │ └── index.html ├── config │ ├── index.html │ ├── hooks.php │ ├── profiler.php │ ├── doctypes.php │ ├── migration.php │ ├── constants.php │ ├── routes.php │ ├── foreign_chars.php │ ├── database.php │ ├── smileys.php │ ├── autoload.php │ └── mimes.php ├── errors │ ├── index.html │ ├── error_php.php │ ├── error_db.php │ ├── error_general.php │ └── error_404.php ├── helpers │ └── index.html ├── libraries │ └── index.html ├── models │ ├── index.html │ └── dropdown_model.php ├── controllers │ ├── index.html │ └── dropdown.php ├── third_party │ └── index.html └── language │ └── english │ └── index.html ├── css └── styles.css ├── .gitignore ├── README.md ├── README.txt ├── js └── dropdown.js ├── cidropdown.sql └── license.txt /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /system/.htaccess: -------------------------------------------------------------------------------- 1 | Deny from all -------------------------------------------------------------------------------- /application/.htaccess: -------------------------------------------------------------------------------- 1 | Deny from all -------------------------------------------------------------------------------- /application/views/html/footer.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /css/styles.css: -------------------------------------------------------------------------------- 1 | body {padding: 20px 40px;} 2 | table {width:50% !important;} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | */config/development 2 | */logs/log-*.php 3 | */logs/!index.html 4 | */cache/* 5 | */cache/!index.html 6 | -------------------------------------------------------------------------------- /system/fonts/texb.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theninthnode/codeigniter-ajax-dropdown/HEAD/system/fonts/texb.ttf -------------------------------------------------------------------------------- /system/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/core/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/fonts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/core/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/hooks/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/logs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/helpers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/language/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/config/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/errors/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/helpers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/models/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/controllers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/third_party/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/pdo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/language/english/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /application/language/english/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/cubrid/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/mssql/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/mysql/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/mysqli/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/oci8/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/odbc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/postgre/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/sqlite/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /system/database/drivers/sqlsrv/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | codeigniter-ajax-dropdown 2 | ========================= 3 | 4 | Example on how to manage category/subcategory select boxes with CI and jQuery 5 | 6 | MySQL DB file in cidropdown.sql. More details in readme.txt -------------------------------------------------------------------------------- /system/language/english/number_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

A PHP Error was encountered

4 | 5 |

Severity:

6 |

Message:

7 |

Filename:

8 |

Line Number:

9 | 10 | -------------------------------------------------------------------------------- /application/views/html/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CodeIgniter Ajax Dropdown 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /application/config/hooks.php: -------------------------------------------------------------------------------- 1 | load->view('html/header');?> 2 |

CodeIgniter Ajax Dropdown

3 |

Select an option to get a list of suboptions. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | load->view('html/footer');?> -------------------------------------------------------------------------------- /application/controllers/dropdown.php: -------------------------------------------------------------------------------- 1 | load->model('dropdown_model'); 6 | } 7 | 8 | function index(){ 9 | $data['options'] = $this->dropdown_model->getOptions(); 10 | $this->load->view('dropdown/index', $data); 11 | } 12 | 13 | function getsuboptions($option_id){ 14 | $this->dropdown_model->option_id = $option_id; 15 | $suboptions = $this->dropdown_model->getSubOptions(); 16 | 17 | header('Content-Type: application/x-json; charset=utf-8'); 18 | echo json_encode($suboptions); 19 | } 20 | } -------------------------------------------------------------------------------- /application/config/profiler.php: -------------------------------------------------------------------------------- 1 | controllers > dropdown.php 8 | This is the default controller that loads the dropdown model and view files and contains method for getting sub options 9 | 10 | - application > models > dropdown_model.php 11 | This is the dropdown model that interacts with the database for pulling options and suboptions 12 | 13 | - application > view > dropdown > index.php 14 | This is the main view that contains the dropdown controls (selects) 15 | 16 | - application > view > html > header.php 17 | Pulled into main view and loads all CSS and JS including CDN version of jQuery 18 | 19 | - js > dropdown.js 20 | This is the main javascript file that performs the Ajax functions and loads JSON values into the select controls 21 | 22 | - cidropdown.sql 23 | SQL file that will create and populate two tables, options and suboptions. 24 | 25 | Credits: 26 | 27 | - Bootsrap CSS by twitter http://twitter.github.com/bootstrap/ 28 | - jQuery - http://jquery.com/ -------------------------------------------------------------------------------- /application/config/doctypes.php: -------------------------------------------------------------------------------- 1 | '', 5 | 'xhtml1-strict' => '', 6 | 'xhtml1-trans' => '', 7 | 'xhtml1-frame' => '', 8 | 'html5' => '', 9 | 'html4-strict' => '', 10 | 'html4-trans' => '', 11 | 'html4-frame' => '' 12 | ); 13 | 14 | /* End of file doctypes.php */ 15 | /* Location: ./application/config/doctypes.php */ -------------------------------------------------------------------------------- /system/language/english/profiler_lang.php: -------------------------------------------------------------------------------- 1 | db->select('id, value') 19 | ->get('options')->result(); 20 | 21 | $options_arr; 22 | 23 | $options_arr['#'] = '-- Please Select Option --'; 24 | 25 | // Format for passing into form_dropdown function 26 | 27 | foreach ($options as $option) { 28 | $options_arr[$option->id] = $option->value; 29 | } 30 | 31 | return $options_arr; 32 | } 33 | 34 | /** 35 | * 36 | * Gets sub options 37 | * returns array 38 | * 39 | **/ 40 | function getSubOptions(){ 41 | if(!is_null($this->option_id)){ 42 | $this->db->select('id, value'); 43 | $this->db->where('option_id', $this->option_id); 44 | $suboptions = $this->db->get('suboptions'); 45 | 46 | // if there are suboptinos for this option... 47 | if($suboptions->num_rows() > 0){ 48 | $suboptions_arr; 49 | 50 | // Format for passing into jQuery loop 51 | 52 | foreach ($suboptions->result() as $suboption) { 53 | $suboptions_arr[$suboption->id] = $suboption->value; 54 | } 55 | 56 | return $suboptions_arr; 57 | } 58 | } 59 | 60 | return; 61 | } 62 | } 63 | ?> -------------------------------------------------------------------------------- /application/errors/error_db.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Database Error 5 | 55 | 56 | 57 |

58 |

59 | 60 |
61 | 62 | -------------------------------------------------------------------------------- /application/errors/error_general.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Error 5 | 55 | 56 | 57 |
58 |

59 | 60 |
61 | 62 | -------------------------------------------------------------------------------- /system/core/Model.php: -------------------------------------------------------------------------------- 1 | $key; 52 | } 53 | } 54 | // END Model Class 55 | 56 | /* End of file Model.php */ 57 | /* Location: ./system/core/Model.php */ -------------------------------------------------------------------------------- /application/errors/error_404.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 404 Page Not Found 5 | 55 | 56 | 57 |
58 |

59 | 60 |
61 | 62 | -------------------------------------------------------------------------------- /js/dropdown.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | $('#options').change(function(){ //any select change on the dropdown with id options trigger this code 3 | $("#suboptions > option").remove(); //first of all clear select items 4 | var option = $('#options').val(); // here we are taking option id of the selected one. 5 | 6 | if(option == '#'){ 7 | return false; // return false after clearing sub options if 'please select was chosen' 8 | } 9 | 10 | $.ajax({ 11 | type: "POST", 12 | url: "/dropdown/getsuboptions/"+option, //here we are calling our dropdown controller and getsuboptions method passing the option 13 | 14 | success: function(suboptions) //we're calling the response json array 'suboptions' 15 | { 16 | $.each(suboptions,function(id,value) //here we're doing a foeach loop round each sub option with id as the key and value as the value 17 | { 18 | var opt = $('