View Full Version : retrieving varible data from listbox content

07-16-2003, 03:39 PM
I've populated a listBox with information from a mySQL database with the use of a PHP script. I wrote this code to do so:

for (i=0; i<Number(searchResults.n)i++) {
itemLabel = searchResults["LastName"+i] + ", " + searchResults["FirstName"+i];
itemLabel += "\t" + searchResults["Company"+i] + "\t" + searchResults["EMailAddress"+i];

Now I am needing to extract the "EMailAddress" variable data value from the selected items in the listBox("lbxAddressDisplay"). I know that I need a for loop and a getSelectedItems() method call, but can't seem to wrap my head around the logic needed to extract the said variables from the listBox. Please help me if you can. I've been going nuts with this problem!

07-16-2003, 05:36 PM
I assume you have a button that will get pressed after all the items are selected in the listBox. Let's say the button has an onrelease handler named getEmails and the listBox has an instance name of myList; myList .getSelectItems() returns an array of objects. In this case we are after data.EMailAddress, so with a simple loop we can access the properties.

function getEmails() {
var foo = myList.getSelectedItems();
for(var i=0;i<foo.length;i++) {
trace (foo[i].data.EMailAddress);

07-16-2003, 06:21 PM
I'll let you know if that solves the problem. Actually, it's very close to what I had already written. Thanks for the help once again. You know, when you originally replied to my post, I was unaware that you were the the one who developed the FreddyGrid component. I actually looked into the FreddyGrid as a solution to my listBox difficulties. It's a very nice component. Although I have no express need for it at this point, no doubt I will have good cause to use it in the future. I'm actually keeping an eye on the AMFPHP Project, and your FreddyGrid relates very closely to the possible front-end applications of their new Actionscript/PHP translation/remoting software.

07-16-2003, 06:40 PM
Thanks alot, I haven't worked on it in some time.


This uses amfphp in conjunction with the grid.

07-16-2003, 08:23 PM
Would you happen to know what the earliest version of PHP that AMFPHP supports is? My webhost only has 3.0 on their servers.

07-16-2003, 08:31 PM
Not sure the answer to your question exactly, but I can tell you 3 ain't gonna cut it. My guess is 4.1 and above.

07-17-2003, 12:57 PM
I updated my function with the modifications you suggested, but it only retrieved one email address from the selected items in the listBox.
Here's the current code:
function mailRecips(){
_root.statusMsg.text="Mail Routine Running...";
mail=new LoadVars;
for (i=0; i<mailArray.length; i++){
_root.statusMsg.text="Mail Object Sent.";

Any ideas on why it's only returning one value?
By the way, if you'd like to take a look at the page this nefarious movie is running on it's:
http:/www.memberminders.com/massMailTest.htm (http://www.memberminders.com/massMailTest.htm)

The "Send Mail" button at the bottom sends the LoadVars object to the PHP script.

07-17-2003, 01:16 PM
Yes, and its because of your for loop.

for (i=0; i<mailArray.length; i++){

Each iteration of the loop is reassigning a value to Emails. What is it you want a comma delimited string? An array? for an array use

Emails = [];
for (i=0; i<mailArray.length; i++){

Now you can send the array off to PHP.