That's off a bit.
function testField(thisField){
myString = "o,b/o,s,h";
myArray = myString.split(",");
for(i = 0; i < myArray.length; i++){
if(thisField.value == myArray[i]){
break
}else
if(myArray.length == (i-1)){
alert('String not in list');
}
}
}
That should be closer.
-----Original Message-----
From: Timothy Heald
Sent: Friday, January 17, 2003 2:04 PM
To: CF-Talk
Subject: RE: -OT- Javascript and lists
I would split the list into an array then loop through like so:
function testField(thisField){
myString = "o,b/o,s,h";
myArray = myString.split(",");
for(i = 0; i < myArray.length; i++){
if(thisField.value == myArray[i]){
break
}
alert('String not in list');
}
}
That should do something like it.
Tim
-----Original Message-----
From: Thane Sherrington [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 17, 2003 1:55 PM
To: CF-Talk
Subject: -OT- Javascript and lists
How do I look through a list of strings in Javascript and compare each to a
variable? I'm trying to do the following:
Set up a list like this "O,B/O,S,H"
And then loop through and compare each the data in a form field and if the
form field doesn't match any of the choices, have it throw an alert.
T
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4