PDA

View Full Version : List of values


avaloncm
11-23-2004, 05:36 PM
Should be easy...

I have the following -

if (choice == 2) {
...

How do I choice from a list of values in the if statement, say 2,3,7,8,10..

Thanks!

Jon Hanlon
11-23-2004, 06:29 PM
if (choice == 2 || choice == 3 || choice == 7 ...)

|| means 'or'
&& means 'and'

avaloncm
11-23-2004, 06:38 PM
I was hoping for something a little more slick, but that works great.

Jon Hanlon
11-23-2004, 07:04 PM
var regExpress = /^(2|3|7|8|10)\s*$/
if (regExpress.test(choice)) ...