PDA

View Full Version : 3rd time lucky - back to basics


dopefries
03-08-2007, 01:30 PM
Hi there,

I've just finished a tutorial on the Flash combobox. Very nice. However, I'm having problems returning the selected value from the combobox.

myData = new LoadVars();
myData.onLoad = function(){
placeTheDataIntoTheRightPlace();
};
myData.load("http://127.0.0.1/transport/ADDROUTE/getroute.php");
placeTheDataIntoTheRightPlace = function(){
for (var i = 0; i<myData.n; i++) {
myComboBox.addItemAt(i,myData.comboData1);
}
};
function showSelected(){
help = myComboBox.selectedItem.toString();
trace(help);
};
myComboBox.addEventListener("change", showSelected);

The PHP

<?php
$dataForCombobox_1 = "This is our FIRST variable, get ready combobox here I come";
$dataForCombobox_2 = "This is our SECOND variable, get ready combobox here I come";

print("&comboData1=$dataForCombobox_1");
print("&comboData2=$dataForCombobox_2");

?>


My first problem is changing comboData1 to fit the loop - comboData+i. I cant make this work properly.
My second problem is that when returning the results from the combobox, all I get is [object Object]. Damn annoying and I cant figure this out.

I hope you can shed some light on my little problem.

Thanks in advance
Dave

dopefries
03-11-2007, 12:47 PM
OK, dont worry about it. 60 hrs later I get my solution. Anybody with the same problem, I hope this helps:

This is how you include the counter in the variable loop construct:
updateOrigin = function () {
for (var i = 0; i<originLoc.n; i++) {
origin_cb.addItemAt(i, eval(["originLoc.name"+i]));
}
};
And this is how you return results from a combobox selection:
getDestinationCoords = function () {
destinationCoords_lv.loc = destination_cb.getSelectedItem().label;
trace("variable "+destinationCoords_lv.loc+" loaded");
destinationCoords_lv.sendAndLoad(filepath+"getcoords.php", destinationCoords_lv, "GET");
};
Any questions just PM me.