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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Var" question

Status
Not open for further replies.

bryanfl100

Technical User
Dec 2, 2005
17
US
Hopefully this is simple. For the following code:

var Item = /157210/;

The 157210 is an id from our database for a product. If I wanted the code above to have multiple id's such as 157210-157290 how could I modify that code to make this work?

Thanks,
Bryan
 
>var Item = /157210/;
>If I wanted the code above to have multiple id's such as 157210-157290 how could I modify that code...
[tt]var Item = /1572([1-8][0-9]|90)/; [/tt]
 
tsujis answer is a regular expression that represents what you want, but if you want to have those numbers in a structure that allows you to loop through then then put them in an array.

Code:
var arItems = [1, 2, 3, 4, 5];

or alternatively
Code:
var arItems = [];
for (var i=startVal; i<endVal; i++)
 arItems[arItems.length] = i;

You might want to expand you question so that we know what you're trying to get to.

Chaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top