11/3/2022 0 Comments Membuat dropdown label blogger
Select one option on "Category", then the option will appear from the "Sub Category" that corresponds. To do the test, open your browser and visit the following URL: $data = $this->product_model->get_sub_category($category_id)->result() Ĭreate a view file named "product_view.php" in the "application/views" folder.ĭynamic Select Option using Codeigniter and Ajax $category_id = $this->input->post('id',TRUE) $this->load->view('product_view', $data) $data = $this->product_model->get_category()->result() Load->model('Product_model','product_model') $query = $this->db->get_where('sub_category', array('subcategory_category_id' => $category_id)) Ĭreate a controller file named "Product.php" in the "application/controllers" folder. In this step, you will learn the basics of select options dependent using Codeigniter and Ajax.Ĭreate a model file named "Product_model.php" in the "application/models" folder. Basic Dependent dropdown in Codeigniter and Ajax 'db_debug' => (ENVIRONMENT != 'production'), Open the database.php file in the "application/config" folder and find the following code: $config = ' Note: if your web server uses a port, include also the port you are using. Open the config.php file in the "application/config" folder and find the following code: Open the autoload.php file in the "application/config" folder and find the following code: #MEMBUAT DROPDOWN LABEL BLOGGER CODE#Select all the code (CTRL + A) and copy then paste it in notepad and save it as jquery-3.3.1.js. If you haven't got jquery, visit the following URL: Next, copy the jquery file into the folder "assets/js" as shown below: Next, create a folder "assets" in the "select-ajax" folder parallel to the application and system folder.Īfter that, extract the Bootstrap file that was previously downloaded into the "assets" folder as shown below: Then rename the CodeIgniter project to be “ select-ajax”.Ĭonsider the following picture for more details: Or to the directory: “C:xampphtdocs” if you use XAMPP. Installing and Configuring CodeigniterĮxtract Codeigniter that you have downloaded earlier to the directory: “C:wampwww” if you use WAMPSERVER. The SQL command above will insert 9 records data into a "sub_category" table. INSERT INTO sub_category(subcategory_name,subcategory_category_id) VALUES The SQL command above will insert 3 records data into a "category" table.Īfter that, Insert some data into the "sub_category" table by executing the following query: ('Baby'),('Womans Fashion'),('Mens Fashion') INSERT INTO category(category_name) VALUES Insert some data into the "category" table by executing the following query: Next, insert some data into the "category" and "sub_category" tables. Product_id INT PRIMARY KEY AUTO_INCREMENT, To create a "product" table can be done by executing the following query: Subcategory_id INT PRIMARY KEY AUTO_INCREMENT, To create a "sub_category" table can be done by executing the following query: To create a "category" table can be done by executing the following query:Ĭategory_id INT PRIMARY KEY AUTO_INCREMENT, In this tutorial, we need 3 tables, namely: category, sub_category, and product. To create a database “ pos_db” in MySQL, it can be done by executing the following query: If you create a database with the same name it's better. To create select options dependent in Codeigniter and AJAX Jquery, here's what you need to prepare:Įven though Bootstrap and Datatable are optional, I strongly recommend that you have all the lists above.īecause I will use all the lists above in this tutorial.Ĭreate a database named “ pos_db”. #MEMBUAT DROPDOWN LABEL BLOGGER UPDATE#Update with Select Option dependent in Codeigniter and Ajax. Displays data that has been inserted into datatable.ħ. Insert with Select Option dependent in Codeigniter and Ajax.Ħ. Basic Dependent dropdown in Codeigniter and Ajax.ĥ. However, if you are a beginner in Codeigniter I suggest you learn " Codeigniter Tutorial for Beginners" first.ģ. #MEMBUAT DROPDOWN LABEL BLOGGER HOW TO#How to create dependent select options, insert, update, and delete with Codeigniter and Ajax. This is the ultimate tutorial about Select Options dependent using Codeigniter and JQuery Ajax.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |