Adobe Dreamweaver Forums



Last 10 THreads :         On hitTest go to next frame? Why doesn't this work? (Last Post : Koolaz Games - Replies : 0 - Views : 1 )           »          Contribue won't allow Images to be inserted (Last Post : RiderAlberta - Replies : 0 - Views : 1 )           »          This just sucks.... (Last Post : TC2112 - Replies : 11 - Views : 12 )           »          Update from array (Last Post : -==cfSearching==- - Replies : 3 - Views : 4 )           »          PHP Notice Problem (Last Post : UteFanJason - Replies : 7 - Views : 8 )           »          Limited Ammo (Last Post : kglad - Replies : 19 - Views : 20 )           »          Icon Text sticks when returning to home page.. (Last Post : kglad - Replies : 1 - Views : 2 )           »          controlling Flash player (Last Post : motonutty - Replies : 0 - Views : 1 )           »          Communicating with FLASH player via actionscript (Last Post : motonutty - Replies : 0 - Views : 1 )           »          button skin (Last Post : Merlyn MM - Replies : 4 - Views : 5 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags: , , ,

Reply
  #1 (permalink)  
Old 07-24-2008, 04:07 PM
projectproofing
 
Posts: n/a
Diggs:
Default mx:list to comma delimited list

Can someone tell me or show me an example of how to loop through the multiple selected items in a mx:List to create a comma delimited list so I can insert them into a database?

Thanks!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2008, 05:10 PM
dimival
 
Posts: n/a
Diggs:
Default Re: mx:list to comma delimited list

Use the selectedItems property, it is an array of the items selected in the List. Just loop through this array and add the elements to the list you want to insert in the db.
Reply With Quote
  #3 (permalink)  
Old 07-25-2008, 04:02 AM
subedimadhav@yahoo.c
 
Posts: n/a
Diggs:
Default Re: mx:list to comma delimited list

you can use
list.selectedItems.join(",");

if you want to insert the selected items into database, i don't think making a
comma delimited string is appropriate, you might have thought to parse this
string in the server side again, but you can pass the list itself to a server
script.

Reply With Quote
  #4 (permalink)  
Old 07-25-2008, 12:24 PM
projectproofing
 
Posts: n/a
Diggs:
Default Re: mx:list to comma delimited list

The selectedItems seems to work, but I am getting object, object. The list is
set to:

<mx:List id="frmProjectTeam" allowMultipleSelection="true" height="110"
width="100%" labelField="name"> </mx:List>

The dataProvider is being set in a function that populates it with a 'name'
and a uniqname (username).

How can I create the list based on the uniqnames selected?

I tried:
projectInfo.assigned = frmProjectTeam.selectedItems.uniqname.join(",");

Reply With Quote
  #5 (permalink)  
Old 07-25-2008, 07:05 PM
ntsiii
 
Posts: n/a
Diggs:
Default Re: mx:list to comma delimited list

selectedItems is an array of *objects*. [Object object] happens when you
attempt to display an object in a component that is expecting a string.

You need to specify the name of the property in the object that contains the
string value you want to use.

Tracy

Reply With Quote
  #6 (permalink)  
Old 07-25-2008, 07:05 PM
ntsiii
 
Posts: n/a
Diggs:
Default Re: mx:list to comma delimited list

Further, join will not work unless your objects were simple strings, which they are not.

So use the loop, and concatenate the name properties:
sNameCSV += item[ i ].name;

Tracy
Reply With Quote
  #7 (permalink)  
Old 07-25-2008, 07:44 PM
projectproofing
 
Posts: n/a
Diggs:
Default Re: mx:list to comma delimited list

Thanks for the help. Sorry I am such a novice:

I tried these, but failed. How off the mark am I?

public function getTeamList(team:Array):String {
var teamMembers:String;
for (var i:Number = 0; i < team.length; i++) {
teamMembers += team[i].uniqname;
}

return teamMembers;
}


private function createProject():void
{
var projectInfo:Object = new Object();
projectInfo.assigned =
getTeamList(frmProjectTeam.selectedItem.data);
projectDAO.create({projectDatarojectInfo});
}

Reply With Quote
  #8 (permalink)  
Old 07-25-2008, 08:51 PM
ntsiii
 
Posts: n/a
Diggs:
Default Re: mx:list to comma delimited list

Close, the first should work. Try this, modified a bit for clarity:
Tracy


public function getTeamList():String {
var aSelectedTeams:Array = frmProjectTeam.selectedItems;
var teamMembers:String = ""; //need to init this or the first += will error
for (var i:Number = 0; i < aSelectedTeams.length; i++) {
teamMembers += aSelectedTeams[i].uniqname;
}
return teamMembers;
}

Reply With Quote
  #9 (permalink)  
Old 07-25-2008, 08:51 PM
ntsiii
 
Posts: n/a
Diggs:
Default Re: mx:list to comma delimited list

Now, that will not add the commas, of course:
teamMembers += aSelectedTeams[i].uniqname + ",";

Add logic if you need to leave the comma off the last value.

Tracy

Reply With Quote
  #10 (permalink)  
Old 07-29-2008, 05:12 PM
projectproofing
 
Posts: n/a
Diggs:
Default Re: mx:list to comma delimited list

I get 'undefined, undefinded, undefined' as my insert value. Do I have to add a
value to the var aSelectedTeams:Array = frmProjectTeam.selectedItems;
such as var aSelectedTeams:Array = frmProjectTeam.selectedItems.uniqname; or
something.

Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:10 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk