Copy link to clipboard
Copied
These values get through the argument:
may
may/jun
and get separated
This does not:
may/jun/jul
What am I doing wrong here?
function Blomstring(ar){
var newAr = [];
var newData = [];
var findEl = false;
var el = "";
for(var i=0; i<ar.length; i++){
findEl = false;
el = ar['Blomstring'];
if(el == '' || el.indexOf('/')!=-1){
continue;
}
for(var j=0; j<newAr.length; j++){
if(newAr
findEl = true;
}
}
if(findEl==false){
newAr.push(el);
}}
Copy link to clipboard
Copied
What are you trying to do?
Copy link to clipboard
Copied
To make it short:
I have list1 that is populated with plant names.
Then I have list2 which is connected to the function shown above, that will filter plants that that bloom in specific months.
My large xml file has however plants that bloom not only in may, but may/jun, may/jun/jul etc.
The if argument in the code shown above makes may/june, show up correctly as both may and jun in filter list2, and it filters list1 correctly. But may/jun/jul, or jul, or jul/aug doesn't show in the filter list2
The problem arises when i have 2 "/" like in jun/jul/aug
.
if(el == '' || el.indexOf('/')!=-1){
continue;
Here is the full function:
function Blomstring(ar){
var newAr = [];
var newData = [];
var findEl = false;
var el = "";
for(var i=0; i<ar.length; i++){
findEl = false;
el = ar['Blomstring'];
if(el == '' || el.indexOf('/')!=-1){
continue;
}
for(var j=0; j<newAr.length; j++){
if(newAr
findEl = true;
}
}
if(findEl==false){
newAr.push(el);
}}
newAr.sort();
for(var k=0; k<newAr.length; k++){
newData.push({'label':newAr
}
list2.dataProvider = new DataProvider(newData);
}
Blomstring(a);
list2.addEventListener(Event.CHANGE, change4);
function change4(event:Event):void {
searchInput.text = "";
filterBlomstring(list2.selectedItem.label,a);
//Deselects the other filter lists
list3.selectedIndex = -1;
list4.selectedIndex = -1;
//
}
function filterBlomstring(filter,ar){
var newData = [];
var newAr = [];
var el = "";
var findEl = false;
for(var j=0; j<ar.length; j++){
el = ar
if(el.indexOf(filter) != -1){
newAr.push(ar
}
}
newAr.sort();
for(var k=0; k<newAr.length; k++){
newData.push({'label':newAr
}
//listAr is what is being populated in "list"
listAr = newAr;
list.dataProvider = new DataProvider(newData);
firstRow();
}
Copy link to clipboard
Copied
I'm still not following what your code is trying to do, but if you want to extract the stuff that lives around the slashes, then you can just use the String.split() method to create an array of the months involves in the string.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now