Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto populate Comboboxes from Variables

Status
Not open for further replies.

mrblonde100

Technical User
Nov 22, 2009
5
0
0
GB
Hi,

I hope you can help me; i might be trying to achieve the impossible. But i thought I would give it ago and see if there are any minds that can put theory into practice ?
I have in fact two questions; in essence what I’m trying to do is pull a series of counties and localities from a database and populate them into two separate combo boxes. The contents of the locality box will be dependent on the county that is selected by the user. So the contents of the locality combo box will automatically change once the county has been selected.

The variables are being sent and flash is picking them up.
Populating the first text box

The variables are formatted thus:
“countid0=34&name0=Berkshire&countid1=32&name1=Hampshire&countid2=30&name2=Devonshire&...”

So each county has an associated value. So in the case of Berkshire, 34. The values are not numerically ordered.

First question!

What i need is for Flash to take the county that it’s being sent and the associated value for that county and pop it into a combo box. Then continue adding the counties and values till there are no more counties left to add. The number might change you see.

I have managed to get it to work using this code:

myComboBox.addItemAt(0,myData.name1); but its not dynamic, and not taking the value and requires all the items to be manually coded in. I imagine a while loop would work, but im unsure how to this would be coded.
Populating the second text box

The variables are formatted thus:

“locid0=34&name0=Newbury& value0=486&locid1=34&name1=Andover&value1=487& locid2=34&name2=Basingstoke& value2=488...”

The locid relates to the county it belongs to, so there is an association. If Berkshire was selected then all the localities would be entered in the second combobox that had the locid of 34.

Does that make sense?

Finally the associated values for each selection would be put in two separate variables

So one var for county and another for locality.
It seems simple in logic, but how this would be coded is beyond me. Is it even possible?

Any advice or guidance is gratefully received.
Many thanks



 
I assume this will be loaded via Actionscript.

You may find that there is a limit to the number of name/value pairs that can be passed.

Either pass them in via an XML file or read the info directly from a PHP/Perl script.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top