简体   繁体   English

如何将Jquery链接应用于多个父级方法

[英]How to apply Jquery Chaining to Multiple Parents method

Need filter course details according to level and semester selectors value..We try it using Chaining to Multiple Parents 需要根据水平和学期选择过滤过程的细节value..We尝试使用链接到多个家长

(One child can also have two parents. Available options on child chained to multiple parents depend on one or both of the parents selected values) (一个孩子也可以有两个父母。链接到多个父母的孩子的可用选项取决于父母选择的一个或两个值)

here code that we try (remove all Chained Selects codes,to get clear idea) 这是我们尝试的代码(删除所有“链式选择”代码,以获得清晰的主意)

<html>
    <head>
    <script type="text/javascript" src="jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="jquery.chained.js"></script>

    </head>
    <body>

    <select name="level" id="level_id">
                 <option value="level-1">Level 1</option>
                 <option value="level-2">Level 2</option>
                 <option value="level-3">Level 3</option>
    </select>

    <select name="semester" id="semester_id">
                 <option value="semester-1">Semester 1</option>
                 <option value="semester-2">Semester 2</option>
     </select>


     <select name="course" id="course_id">
                 <option value="1">Multimedia</option>
                 <option value="10">Botany Practicals II</option>
                 <option value="9">Genetics</option>
                 <option value="4">Plant Diversity Unity & Evolution</option>
                 <option value="6">Plant Anatomy</option>
                 <option value="5">Scientific Approach & Biometrics</option>
                 <option value="11">Advanced Ecology</option>
                 <option value="12">Advanced Plant Pathology </option>
                 <option value="7">Advanced Microbiology</option>
                 <option value="8">Economic Botany</option>
                 <option value="13">Cropping System</option>
                 <option value="14">Food Technology</option>
     </select>

    </body>
    </html>

Here how course will be filter according to the level and semester 在这里如何根据级别和学期筛选课程 在此处输入图片说明

But unable to understand how to apply that code.Please help us.. 但无法理解如何应用该代码。请帮助我们。

Jquery Code: Jquery jQuery代码: Jquery

You should chain the select with their id 您应该将选择项与其ID链接在一起

$("#course_id").chained("#level_id, #semester_id");

EDIT : added a test fiddle : http://jsfiddle.net/scaillerie/VwuvY/ . 编辑:添加了一个测试提琴: http : //jsfiddle.net/scaillerie/VwuvY/

EDIT 2 : in order to get the filter on 2 preceding lists, the class should be composed of the 2 values separated by a \\ (for example, for first semester and first level, the class should be level-1\\semester-1 . Updated fiddle : http://jsfiddle.net/scaillerie/VwuvY/1 . 编辑2:为了获得前面2个列表中的过滤器,该类应由两个用\\分隔的值组成(例如,对于第一学期和第一级,该类应为level-1\\semester-1 。更新的提琴: http : //jsfiddle.net/scaillerie/VwuvY/1

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

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