简体   繁体   English

在杂货CRUD(CodeIgniter)中依赖下拉

[英]Dependent Drop down in Grocery CRUD (CodeIgniter)

I stucked in a Problem When Playing with Drop Downs.I tried to use this http://www.grocerycrud.com/forums/topic/1087-updated-24112012-dependent-dropdown-library/ 我在使用Drop Downs时遇到了一个问题。我试图使用这个http://www.grocerycrud.com/forums/topic/1087-updated-24112012-dependent-dropdown-library/

But actually my requirement is quite different. 但实际上我的要求是完全不同的。 I have a table fwld_products in which i am adding all other table's categories, from 我有一个表fwld_products ,其中我正在添加所有其他表的类别

fwld_cat_main (main Category's ID), fwld_cat_main (主要类别的ID),

fwld_cat_sub1 (sub1 Category's id) fwld_cat_sub1 (sub1类别的id)

fwld_cat_sub2 (sub2 Category's id) fwld_cat_sub2 (sub2类别的id)

fwld_cat_sub3 (sub3 Category's id) fwld_cat_sub3 (sub3类别的id)

I want to Display Dropdown in such a way, when user Selects main Category, the Drop Down Appear (sub1) Having Data related to main category and when sub1 selected drop down appear (sub2) showing data related to sub1, and sub2 selected and drop down appear(sub3) to show data related to Drop down (sub2). 我希望以这种方式显示下拉,当用户选择主类别时,下拉显示(sub1)具有与主类别相关的数据,当选择sub1时下拉显示(sub2)显示与sub1相关的数据,并且sub2选择并删除down(sub3)显示与下拉(sub2)相关的数据。

When submitted Finnally data inserted to [fwld_products] . 当提交Finnally数据时插入[fwld_products]

Here I am attaching ERD, and result as well. 这里我附上了ERD,结果也是如此。

在此输入图像描述在此输入图像描述

Please help 请帮忙

Hold on, it seems that DB structure of your categories table needs to be improved. 等等,您的类别表的DB结构似乎需要改进。 What I suggest is that you follow footprints from some of the popular CMS like Opencart. 我建议您遵循一些流行的CMS(如Opencart)的足迹。 It will give you a great sense to accomplish your task. 它将为您完成任务提供很好的意义。 You can easily optimize your DB by using just one "category" table (instead of main, sub1, sub2, and sub3 category tables) like this: 您只需使用一个“类别”表(而不是main,sub1,sub2和sub3类别表)就可以轻松优化数据库,如下所示:

类别

For category names, description, and meta keywords etc you can create this table "category_description": 对于类别名称,描述和元关键字等,您可以创建此表“category_description”:

category_description

Finally to assign categories to the products you can simply create another table "product_to_category": 最后,要为产品分配类别,您只需创建另一个表“product_to_category”:

product_to_category

In this way you can easily manage your data in DB and you can now easily tackle your situation using Codeigniter and Grocerycrud. 通过这种方式,您可以轻松地在数据库中管理数据,现在您可以使用Codeigniter和Grocerycrud轻松解决您的情况。

Try, Chained Selects Plugin for jQuery and Zepto ( Github Project | Project Home ) 试试, 链接为jQuery和Zepto选择插件Github Project | Project Home

If you use or in your project, this plugin will help you to solve your problem, Specially the remote version . 如果你在项目中使用 ,这个插件将帮助你解决你的问题,特别是远程版本 You can create related select boxes easily. 您可以轻松创建相关的选择框。

Hope this helps :) 希望这可以帮助 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM