Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-06-2005, 03:28 PM   #1
Xman51
Freedom Fighter
 
Xman51's Avatar
 
Join Date: Apr 2005
Location: wwwroot
Posts: 93
Send a message via AIM to Xman51
Question LoadVars not working

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
Xman51 is offline   Reply With Quote
Old 07-06-2005, 03:34 PM   #2
quincewyss
Peak Studios Boulder, CO
 
Join Date: Mar 2002
Location: Boulder, CO
Posts: 214
Default

you need to call label: or data: in your array.

ActionScript Code:
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({label:this["Name"+i], data:this["Name"+i]});                }           }else{                trace("fail!!!")           }      };

I put in both the label: and data: to show you how it works.
quincewyss is offline   Reply With Quote
Old 07-06-2005, 03:42 PM   #3
Xman51
Freedom Fighter
 
Xman51's Avatar
 
Join Date: Apr 2005
Location: wwwroot
Posts: 93
Send a message via AIM to Xman51
Default

Thanks for the reply quince!

Though, that doesn't seem to be solving the problem...notice the trace I have in loadVars function(success)? It doesn't trace anything it is like it never gets to that portion of the code...

ActionScript Code:
trace("cmb"+curName[j]);

I can't figure out why....can you?

Thanks again,

Xman51
Xman51 is offline   Reply With Quote
Old 07-07-2005, 03:21 AM   #4
quincewyss
Peak Studios Boulder, CO
 
Join Date: Mar 2002
Location: Boulder, CO
Posts: 214
Default

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++){      lvIn.ID = curName[j];      trace(curName[j]);      lvIn.sendAndLoad(path + "Combo.php", lvIn, "POST");      lvIn.onLoad = function(sucess) {           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", lvOut, "POST");      lvOut.onLoad = function() {          trace("info has gone out");                }      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);       } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
quincewyss is offline   Reply With Quote
Old 07-07-2005, 03:48 AM   #5
bjtplett
Registered User
 
Join Date: Jul 2005
Posts: 3
Lightbulb

ActionScript Code:
lvIn.onLoad = function(sucess) {           if (success) {

Did you copy your code directly? If so, check the spelling of success.
bjtplett is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:54 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.