how about state[2]= structNew(); state[2].name = "New York"; state[2].addb = "NY";
just adding each state into a new index of the first dimension. Actually, theres no real need to use an array at all, it could all be a struct:
state = structNew(); state["AL"] = "Alabama"; state["NY"] = "New York"; state["MA"] = "Massachusettes";
<select name="states">
<cfloop collection="#states#" item="i">
<cfoutput><option value="#i#">#states[i]#</option></cfoutput>
</cfloop>
</select>At 03:03 PM 10/6/2003 -0700, you wrote:
Adam: Then, how would you advanced to the next state by using single Dim Array?
<cfscript> state = arrayNew(1); state[1] = structNew(); state[1].name = "Alabama"; state[1].abbv = "AL"; ...
state[?].name = "Washington"; state[?].abbv = "WA";
return state; </cfscript>
-----Original Message----- From: Adam Wayne Lehman [mailto:[EMAIL PROTECTED] Sent: Monday, October 06, 2003 10:49 AM To: [EMAIL PROTECTED] Subject: RE: [CFCDev] Using Structs
Any drawback to doing it this way?
<cfscript> state = arrayNew(1); state[1] = structNew(); state[1].name = "Alabama"; state[1].abbv = "AL"; ... return state; </cfscript>
I think it's just easier to read and loop over state[index].name or state[index].abbv. So the question is... which has a faster execute?
Adam Wayne Lehman Web Systems Developer Johns Hopkins Bloomberg School of Public Health Distance Education Division
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wayne Graham Sent: Monday, October 06, 2003 1:20 PM To: [EMAIL PROTECTED] Subject: [CFCDev] Using Structs
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I'm having a minor problem thinking this afternoon. I have a CFC that returns state abbreviations and state names as a structure. For the life of me, I can't remember how to loop over the structure to input it into a select box. Here's a sample of the cfc:
<cfscript> a = structNew(); a.state = ArrayNew(2);
a.state[1][1] = "AL"; a.state[1][2] = "Alabama"; ... return a; </cfscript>
I just can't seem to loop over the structure properly using <cfloop>...
Am I using the structure properly? Should this just be an array passed back? Are there conventions for this?
The final output I'm looking for is:
<select name="state"> <option value="AL">Alabama
I just keep getting various java errors. Can someone help?
Thanks, Wayne
************************************** Wayne Graham Systems Office Earl Gregg Swem Library College of William and Mary PO Box 8794 Williamsburg, VA 23187-8794 757.221.3112
-----BEGIN PGP SIGNATURE----- Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>
iQA/AwUBP4GkI1uRxBfF5S5XEQL5KACg0ai+NLynloTFcEMtNu7ak5T+kOEAniLf PFTAULfYIziYpaIXO+FrL6xs =sG/k -----END PGP SIGNATURE-----
---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
Jeff Tapper [EMAIL PROTECTED] Radio Free Astoria http://radio.tapper.net ========== "They who would give up an essential liberty for temporary security, deserve neither liberty or security" - Ben Franklin
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
