# Multiple comboboxes from php

**URL:** <https://forum.kirupa.com/t/multiple-comboboxes-from-php/26966>\
**Category:** Uncategorized\
**Created:** [July 28, 2003, 8:07pm UTC](https://forum.kirupa.com/t/multiple-comboboxes-from-php/26966 "2003-07-28T20:07:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tripwire](https://avatars.discourse-cdn.com/v4/letter/t/ccd318/32.png) [@tripwire](https://forum.kirupa.com/u/tripwire)\
**Post date:** [July 28, 2003, 8:07pm UTC](https://forum.kirupa.com/t/multiple-comboboxes-from-php/26966/1 "2003-07-28T20:07:04Z")

</div>

Hi, I’ve been having a problem using comboboxes to read from a php script. I want to use around 6 different comboboxes to control a number of different movie clips. I have everything working fine reading from 1 combobox using the following code:

php script:

```php

<?php
$NameArr = array("Headphones", "Sunglasses", "Hat");
$DataArr = array("headphones", "sunglasses", "hat");
for($i=0;$i<count($NameArr);$i++) {
$data[] = $NameArr[$i].":".$DataArr[$i];
}

print implode("
", $data);
?>

```

Flash:  
[AS]  
//Create a new instance of the LoadVars object  
myVars = new LoadVars();

//Load the text file  
myVars.load(“loadCombo.php”);

//Run this when the data has loaded  
myVars.onData = function(raw) {  
//Split the loaded text into an array by newline  
tmp = raw.split("  
“);  
//Loop through the array  
for(var i=0;i\<tmp.length;i++) {  
//make a new array from each element of the first array splitting on the | symbol  
tmp2 = tmp\*.split(”:");  
//Add an item to the comboBox for this element of the text file  
myCombo.addItem(tmp2[0], tmp2[1]);  
}  
}

//Selection - Select MC  
mycombo.setChangeHandler(“onChange”);  
onChange=function()  
{  
\_root.man[selected].\_visible = false;  
selected = mycombo.getValue();  
\_root.man[selected].\_visible = true;   
}

function traceCombo(com) {  
trace (“Selected Data: " + com.getSelectedItem().data);  
trace (“Selected Label: " + com.getSelectedItem().label);   
trace (”--------------------------------------”);   
}

[/AS]

Now I’m having trouble figuring out what would be the best way to go about reading to multiple comboboxes without creating a number of different functions? Would I be able to redefine the current function to load text into multiple comboboxes from my php script? I’m not sure how to sort out my arrays either.

---

<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:** [July 29, 2003, 5:46am UTC](https://forum.kirupa.com/t/multiple-comboboxes-from-php/26966/2 "2003-07-29T05:46:01Z")

</div>

Ok, I’ve spent all night trying to figure this out but have not been able to solve it yet. I’ve read through all kinds of tutorials and forums, but I don’t see a solution. Does anyone have any ideas? How do I get $data[] and $data2[] into separate comboboxes?

Here is what I was trying:

PHP script:

```php

<?php
$NameArr = array("Headphones", "Sunglasses", "Hat");
$DataArr = array("headphones", "sunglasses", "hat");
$NameArr2 = array("Short", "Spiked", "Afro");
$DataArr2 = array("hairShort", "spiked", "afro");
for($i=0;$i<count($NameArr);$i++) {
$data[] = $NameArr[$i].":".$DataArr[$i];
}
for($i=0;$i<count($NameArr2);$i++) {
$data2[] = $NameArr2[$i].":".$DataArr2[$i];
}

print implode("
 a", $data);

print implode("
 b", $data2);
?>

```

Flash:

[AS]  
//Run this when the data has loaded  
myVars.onData = function(raw) {  
//Split the loaded text into an array by newline  
tmp = raw[“a” + i].split("  
");

```
    //Loop through the array
    for(var i=0;i&lt;tmp.length;i++) {
            //make a new array from each element of the first array splitting on the | symbol
            tmp2 = tmp*.split(":");
			
            //Add an item to the comboBox for this element of the text file
            myCombo.addItem(tmp2[0], tmp2[1]);
			
    }

```

[/AS]
