Can the listbox data variable be a string?

Hello,
I followed the tutorial on listbox management and applied it to a project I’m working on, but I can’t get it to work. Can the “data” variable in the listbox be a string? I can’t get it to work.

The tutorial uses this:

list.addItem("My birthday",new Date(2002,4,9));

I’d like to use arrays that contain text for mine:

list_of_terms.addItem(wordList[0],definitionList[0]);

where wordList[0] is equal to “cat” and definitionList[0] is equal to “meow, meow”

It doesn’t seem to work, does anybody have any ideas on this?


list_of_terms.addItem({label:wordList[0],data:definitionList[0]});

try that :wink:

OK, I now have a listbox that is working, I am populating it by typing into input textboxes, any ideas on how to delete a particular entry, the following only seems to delete the first reference in the list, not the selected.

My code to populate the box:

stop();
var wordList = new Array();
var definitionList = new Array();
var j;
var i;
function saveWord() {i = "\"" + word + "\"";
j = "\"" + definitions + "\"";
wordList.push(i);
definitionList.push(j);
}

function displayDetails(c){
		 var j = c.getSelectedItem().data;
		 textbox.htmlText = c.getSelectedItem().data;
		  	 }

			 
// 3
listbox.setChangeHandler("displayDetails");


and then the button I’m trying to set up to delete a selected listbox item:

on (press) {
	listbox.removeItemAt(j);
	}

on (release) {
	_parent.listbox.removeItemAt(_parent.listbox.selectedIndex);
}

Thank you, I’m working on the next step now.