Hello All,
I can't seem to get this loadvars to work. I have 7 comboboxes on the stage whose names I have put into an array. The values in the array are used not only for the combobox names but to send info to php using loadVars. I am trying to loop through all of the combo boxes to populate them and it doesn't seem to be working. Can anyone see where I am going wrong???
ActionScript Code:
stop();
//Gender Combobox:
cmbGender.addItem("Male");
cmbGender.addItem("Female");
//Size Combobox:
cmbSize.addItem("Small");
cmbSize.addItem("Medium");
cmbSize.addItem("Large");
//Race Combobox:++++++++++++++++++++++++++++++++++++++++++++++++
path = "http://localhost/kikaijin/"; //declare path to php files
var lvIn = new LoadVars();
var lvOut = new LoadVars();
var curName:Array = new Array("Race", "Hair", "Shirt", "Pants", "Shoes", "Armor", "Weapon")
for (var j=0; j<curName.length; j++){
lvOut.ID = curName[j];
trace(curName[j]);
lvIn.onLoad = function(success) {
if (success) {
var items = parseFloat(this.NumItems);
for (var i = 0; i<items; i++) {
trace("cmb"+curName[j]);
this["cmb"+curName[j]].addItem(this["Name"+i]);
}
}else{
trace("fail!!!")
}
};
lvOut.sendAndLoad(path + "Combo.php", lvIn, "POST");
var listener = {};
listener.change = function(event_obj) {
var url = event_obj.target.selectedItem.data
trace(url);
getURL(url, "_blank");
};
this["cmb"+curName[j]].addEventListener("change", listener);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
And here is my php which is working properly as far as I can tell aside from doubling the output:
PHP Code:
<?php
$ComboID= $_POST['ID'];
//Open the connection
$conn=odbc_connect('Combo','xman51','area51');
if (!$conn)
{
exit("Connection Failed: " . $conn);
}
$sql="SELECT * FROM &ComboID;";
//echo $sql;
$rs=odbc_exec($conn, $sql);
$Colnum=odbc_num_fields($rs);
while(odbc_fetch_into($rs,&$Str))
{
for($j=0;$j<$Colnum;$j++)
{
$RaceN[] = $Str[1];
}
}
if (!$rs)
{
exit("Error in SQL");
}
$numReturn = count($RaceN);
$i = 0;
print "&";
while ($i < $numReturn) {
$Name = $RaceN[$i];
print "Name$i=$Name";;
$i++;
}
print "&NumItems=$numReturn";
?>
Please help!!!
Thanks in Advance,
Xman51