This will either return 0 if the string isn't found or the array position in
which it was found
<cfscript>
function searchArray(arr,str)
{
var retVal = 0;
for(i=1; i lte arraylen(arr); i=i+1)
{
if (arr[i] is str)
{
retVal = i;
break;
}
}
return retVal;
}
</cfscript>
Just use it like....
#searchArray(myArray,'XYZ')#
..:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
http://cf4em.com
-----Original Message-----
From: nic olai [mailto:[EMAIL PROTECTED]
Sent: Monday, June 23, 2008 8:54 AM
To: CF-Talk
Subject: How to select an entry from an array
Hi all,
i want to send data with a post form. In the next step i want to check which
entry of an array includes the selected data.
For example:
In the form the user selected the 2nd entry which includes XYZ in an
dropdown (select) field and submit the form.
How can i check which entry of the array myarraytest[] includes the data
XYZ.
Thank you & best regards
nic.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308002
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4