There is no bult in function to do that
so here is one i knocked up for you
<script>
tmpArray = new Array("1,2,3,4,5,677,77");
function arrayFind(array,str)
{
findString = "," + str + ",";
arrayAsString = "," + array.toString() + ",";
if (arrayAsString.indexOf(findString) != -1)
{return
arrayAsString.substring(0,arrayAsString.indexOf(findString)).split(",").leng
th-1;}
else
{return null;}
}
alert(arrayFind(tmpArray,"7"));
</script>
This will return either the position in the array the value is found, or
null if no value is found
with a little playing around you could add in some case sensitivity checking
aswell
have fun
Steve Onnis
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Gareth
Edwards
Sent: Monday, February 16, 2004 2:45 PM
To: CFAussie Mailing List
Subject: [cfaussie] Searching an Array in javascript.
How do I search for a value in an array in javascript
Gareth
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004