# Can the listbox data variable be a string?

**URL:** https://forum.kirupa.com/t/can-the-listbox-data-variable-be-a-string/111305
**Category:** Uncategorized
**Created:** [May 25, 2004, 6:25pm UTC](https://forum.kirupa.com/t/can-the-listbox-data-variable-be-a-string/111305 "2004-05-25T18:25:14Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Sparky\_J](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@Sparky\_J](https://forum.kirupa.com/u/Sparky_J)
#### Post date: [May 25, 2004, 6:25pm UTC](https://forum.kirupa.com/t/can-the-listbox-data-variable-be-a-string/111305/1 "2004-05-25T18:25:14Z")

</div>

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:

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

```

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

```auto
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?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 25, 2004, 9:46pm UTC](https://forum.kirupa.com/t/can-the-listbox-data-variable-be-a-string/111305/2 "2004-05-25T21:46:46Z")

</div>

```auto

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

```

try that 😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 2:13pm UTC](https://forum.kirupa.com/t/can-the-listbox-data-variable-be-a-string/111305/3 "2004-05-26T14:13:15Z")

</div>

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:

```auto
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:

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

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 3:09pm UTC](https://forum.kirupa.com/t/can-the-listbox-data-variable-be-a-string/111305/4 "2004-05-26T15:09:48Z")

</div>

```auto

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

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 4:13pm UTC](https://forum.kirupa.com/t/can-the-listbox-data-variable-be-a-string/111305/5 "2004-05-26T16:13:20Z")

</div>

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