Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"IN" Function ? 1

Status
Not open for further replies.

statjunk

Technical User
Nov 14, 2006
3
US
Hello All,

I've searched the internet but with a generic search of IN, I can't find any help.

Is there a way in javascript to say IN or Not IN

For example I want to say

J.Product_Code IN ('A', 'B', 'C')

or

J.Product_Code NOT IN ('A', 'B', 'C')

Thanks

Tom
 
var searchString = "a,b,c";
var searchStringArray = searchString.split(",");
var codeIsIn = false;
for(i = 0; i<searchStringArray.length&&!codeIsIn; i++) {
if(j.product_code == searchStringArray)
{
codeIsIn=true;
}
}
if(codeIsIn)
{
alert("Product Code is in list");
} else {
alert("Product Code is not in list");
}
 
Thank you for the response.

I need the function to be built in. I can't use this type of code in the envirnment that I'm working in. Sorry for the confusion.

In needs to be more like an excel function and not like a piece of code.

I'm working with a software called Hyperion. It has javascript function windows that I can write simple javascript in.

Thanks anyway though.

Anyone else have an answer to this one?

Thanks

Tom
 
Anyone else have an answer to this one?

Are you asking if there's a built in function in javascript that does exactly what you're wanting? The answer is no.


It wouldn't be hard to write up a prototype method to perform this functionality, but you apparently seem limited on what you can do - writing functions is out of the question it would seem.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Thanks! At least now I know there is no better way.

Tom
 
Good job Adam! That's just what I was about to recommend!

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top