我正在尝试根据先前的选择显示一个下拉列表。这没用。它给了我列出的所有值。ticket_fields_21114185 是我的第一个下拉列表,其中包含 [desktop, web browser] 等值。ticket_fields_21108325 是我的第二个下拉列表,其中列出了所有其他值。
$j(document).ready(function() {
var ren
var dtop = ['windows_7'];
var webrow= ['all','chrome','ie'];
//this builds the dropdown list
Buildoptions = {
selected: function(value, name){
return '<option value="'+value+'" selected="selected">'+name+'</option>';
},
notselected: function(value, name){
return '<option value="'+value+'">'+name+'</option>';
},
clear: function(){
return '<option value=""></option>';
}
}
//goes through the selected array and builds the options
var makeSelection = function(theField, theArray) {
for ( x = 0; x < theArray.length; x++ ) {
console.log('makeing select ' + theArray)
if (x == 0)
$j(''+ theField +'').append(Buildoptions.notselected(theArray[x], theArray[x]));
}
}
$j('select#ticket_fields_21114185').change( function(){
ren=$j('select#ticket_fields_21114185 option:selected').val();
if(ren=='desktop'){
makeSelection('select#ticket_fields_21108325',dtop);
}
else
makeSelection('select#ticket_fields_21108325',webrow)
});
});