Copy link to clipboard
Copied
Hello there!
I'm looking for a workaround preventing a ComboBox displaying item #0 in the dropdown list.
Example:
Items in the CB:
"Choose...", "" (#0, appears as selectedItem at start)
"label 1", "data 1"
"label 2", "data 2"
"label 3", "data 3"
When clicked, the CB displays the four items in the dropdown list.
That's bad!
I just want it to display in the dropdown list:
"label 1", "data 1"
"label 2", "data 2"
"label 3", "data 3"
Repeating item #0 in the the dropdown list is annoying and useless.
I thank you in advance for your help!!!
Copy link to clipboard
Copied
i don't know why you're including something you don't want to display but you can also use the selectedIndex property of your combobox to display whatever you want.
Copy link to clipboard
Copied
Hello kglad !
Thanks for replying.
Years ago you have helped me so many times... (my username was "Germaris").
Good to read from you again.
Thought I was clear in my first post...
Let me elaborate and explain:
I must indicate to users the purpose of my CB: "Choose...". Right?
I must include this item (index 0). I have no choice.
So, when the user clicks he knows what he/she is doing.
The dropdown list appears and "Choose..." is repeated in the list!!! Why?
I dont want "Choose..." to be repeated.
I previously said it is annoying and useless.
The displayed list must begin with item 1 (index 1).
I made several attempts and amongst them some using the selectedIndex property with no results.
Copy link to clipboard
Copied
one way (among many) to do this would be to use the removeItemAt(0) when your combobox opens and addItemAt(0) (if nothing is selected and you want that 'choose' to redisplay).
Copy link to clipboard
Copied
Thank you for your advices and efforts.
Alas, I'm unable to make this works...
The code below didn't change anything.
Don't understand where are my mistakes.
Five years without coding make it difficult for me...
PS : I didn't try yet the solution using a MC.
-----------------------------------------------
var myNav = new LoadVars();
myNav.onLoad = function() {
pages_array = this.pages.split(",");
donnees_array = this.donnees.split(",");
for (i=0; i<pages_array.length; i++) {
if (i>=pages_array.length) {
break;
}
CBNAV.list.addItem(pages_array,donnees_array);
}
};
//CBNAV.addItem("Choisir une recherche...","");
CBNAV.addItem("générale","base");
CBNAV.addItem("d’homonymes","homon");
CBNAV.addItem("de cursus","cursus");
CBNAV.addItem("par écoles","ecoles");
CBNAV.addItem("nominative","nom");
CBNAV.addItem("par année d’entrée","promo");
CBNAV.addItem("géographique de base","geo");
CBNAV.addItem("par régions et pays","reg");
CBNAV.addItem("par départements de France","depts");
CBNAV.addItem("par code postal de France","postal");
CBNAV.addItem("par matricule","matr");
CBNAV.addItem("par adresse de courriel","courr");
CBNAV.addItem("par numéro de téléphone","teleph");
CBNAV.addItem("de nos chers disparus","disp");
CBNAV.addItem("avis de recherche","rech");
CBNAV.addItem("avis de retrouvailles","retr");
CBNAV.rowCount = 24;
//
var CBNAVListener = new Object();
CBNAVListener.change = function(evtnav) {
var nav = new LoadVars();
nav = evtnav.target.selectedItem.data;
if (nav != "") {
nav = nav.toString();
gotoAndStop(nav);
trace(nav);
CBFCT.selectedIndex = 0;
_level4.unloadMovie();
} else if (nav == "" && CBFCT.selectedIndex == 0) {
gotoAndStop("u_nav");
setUpFct();
}
};
CBNAV.addEventListener("change",CBNAVListener);
//
CBNAV.addEventListener("open",removeItemAt(0));
CBNAV.addEventListener("close",addItemAt(0, "Choisir une recherche..."));
//
gotoAndStop.nextFrame;
Copy link to clipboard
Copied
uncomment:
CBNAV.addItem("Choisir une recherche...","");
and add:
var executeOnce:Boolean;
CBNAVListener.change = function(evtnav) {
if(!executeOnce && evtnav.target.selectedItem==CBNAV.getItemAt(0)){
CBNAV.addItem("Choisir une recherche...","");
executeOnce=true;
}
CBNAVListener.open=function(){
CBNAV.removeItemAt(0);
}
CBNAV.addEventListener("open",CBNAVListener);
Copy link to clipboard
Copied
// This is the code I’m using.
// CBNAV is the ComboBox instance name
// CBFCT is the instance name of another ComboBox located on the same page (not related to the use of CBNAV)
// The CBNAV parameter label value is “Choisir une recherche…” which in french means “Choose a search mode…”.
// “pages” corresponds to “label”
// “donnees” corresponds to “data”
// You can see that the addItem list begins with the item1 which I want to be the first to be displayed in the dropdown list
// Everything is working fine
var myNav = new LoadVars();
myNav.onLoad = function() {
pages_array = this.pages.split(",");
donnees_array = this.donnees.split(",");
for (i=0; i<pages_array.length; i++) {
if (i>=pages_array.length) {
break;
}
CBNAV.list.addItem(pages_array,donnees_array);
}
};
CBNAV.addItem("générale","base");
CBNAV.addItem("d’homonymes","homon");
CBNAV.addItem("de cursus","cursus");
CBNAV.addItem("par écoles","ecoles");
CBNAV.addItem("nominative","nom");
CBNAV.addItem("par année d’entrée","promo");
CBNAV.addItem("géographique de base","geo");
CBNAV.addItem("par régions et pays","reg");
CBNAV.addItem("par départements de France","depts");
CBNAV.addItem("par code postal de France","postal");
CBNAV.addItem("par matricule","matr");
CBNAV.addItem("par adresse de courriel","courr");
CBNAV.addItem("par numéro de téléphone","teleph");
CBNAV.addItem("de nos chers disparus","disp");
CBNAV.addItem("avis de recherche","rech");
CBNAV.addItem("avis de retrouvailles","retr");
CBNAV.rowCount = 24;
// Listener
var CBNAVListener = new Object();
CBNAVListener.change = function(evtnav) {
var nav = new LoadVars();
nav = evtnav.target.selectedItem.data;
if (nav != "") {
nav = nav.toString();
gotoAndStop(nav);
trace(nav);
CBFCT.selectedIndex = 0;
_level4.unloadMovie();
} else if (nav == "" && CBFCT.selectedIndex == 0) {
gotoAndStop("u_nav");
setUpFct();
}
};
CBNAV.addEventListener("change",CBNAVListener);
gotoAndStop.nextFrame;