View Full Version : String Question

03-19-2012, 03:25 PM

I need your help.

How could I write a functional if statement such that it would check against a series of various word strings seperated by commas ie.

function check(y) {

//y = "FOR INPUT"

var string_to_check = FOR INPUT, FOR ACTION, FOR APPROVAL

if (y isin string_to_check) { return 1 }


Thanks for everyones help.


03-19-2012, 03:43 PM
maybe setting up arrays with multiple string values and compare that to a array

03-19-2012, 03:51 PM
Check indexOf and see if it is something other than -1

If so, then the string you are searching for does exist in your list of possible values.

It would look about like this:

function check(y){
//y = "FOR INPUT"
var string_to_check = "FOR INPUT,FOR ACTION,FOR APPROVAL";
return true;
return false;

03-19-2012, 03:59 PM
Awesome work Rowsdower!

Works like a charm.

Thank you sooooooooo much.

Cheers and have a great day!


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum