根据先前的选择过滤三个选择框 [英] Filter three select boxes based on previous selections

查看:85
本文介绍了根据先前的选择过滤三个选择框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据先前选择的内容更改选择框. 我希望第一个要更改,但第三个不更改. 如果有人可以帮我做第三件作品,那就太好了.

I am trying to change select boxes in order based on what is previously selected. I have it working for the first one to change but not the third. If someone can help me make third one work that would be great.

http://jsfiddle.net/Ze5AA/21/

这是我正在使用的js:

Here is the js I am using:

$("#CAT_Custom_496270").change(function() { 
    if($(this).data('options') == undefined){
        $(this).data('options',$('#CAT_Custom_495029 option').clone());
    } 

    var id = $(this).val();
    var options = $(this).data('options').filter('[value*=' + id + ']');
    $('#CAT_Custom_495029').html(options);
});

$("#CAT_Custom_495029").change(function() { 
    if($(this).data('options') == undefined){
        $(this).data('options',$('#CAT_Custom_495038 option').clone());
    } 
    var id = $(this).val();
    var options = $(this).data('options').filter('[value*=' + id + ']');
    $('#CAT_Custom_495038').html(options);
});

推荐答案

value attribute过滤器的值括在引号中,因为值中有空格.

Wrap your value attribute filter's value in quotes, since there is a space in the values.

var options = $(this).data('options').filter('[value*="' + id + '"]');

小提琴

Fiddle

这篇关于根据先前的选择过滤三个选择框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆