...

View Full Version : how do i 'if-not' a large ammount of strings/values?



vkidv
04-11-2003, 07:09 PM
how do i say if-not for a alot of strings? can i put these strings in an array and if!=<arrayname>?

i need help, please help.

EDIT: I need to validate a string of text. It has to be one of the one(s) stated (they will be loads of these)

the else function is not any use since there is to many...

Skyzyx
04-11-2003, 07:26 PM
Your question is pretty vague, but the logic goes like this:



if (this == that) // If they are equal

if (this != that) // If they are not equal


I hope this is what you're looking for.

vkidv
04-11-2003, 07:43 PM
yes, but thats not what i need. thanks for trying.

i need somthing which
if (somthing!=tosomthing)

can 'right' ones be put into an array?
tosomthing= new array(10)
tosomthing[0]="Helllo"
tosomthing[1]="ByeBye"
tosomthing[2]="What"

and if somthing is not equal to 'tosomthing itcalls the next thing up?
is this possible?

beetle
04-11-2003, 07:53 PM
Yes. Elaborate on the data you have, cuz all these 'somethings' are making me dizzy :(

Roy Sinclair
04-11-2003, 08:00 PM
Perhaps the following sample page will show you how to do this easily:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Testing</title>
<script language="javascript" type="text/javascript">
var tosomthing = new Array(10);
tosomthing[0]="Helllo";
tosomthing[1]="ByeBye";
tosomthing[2]="What";
function inarray(ar,it)
{
return (ar.join(' ').indexOf(it) < 0) ? false : true;
}
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
document.write(inarray(tosomthing,'ByseBye'));
document.write('<br />');
document.write(inarray(tosomthing,'ByeBye'));

</script>
</body>
</html>

beetle
04-11-2003, 08:16 PM
If that's the case, some posts (http://www.codingforums.com/showthread.php?s=&threadid=18030) were just made about that (roughly)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum