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!

length of values in string

Status
Not open for further replies.

tester321

Programmer
Mar 13, 2007
150
CA
Hi i have a variable called sInventoryIDs which can contain many IDs, each being seperated by a "~" like so:
234~34555~345~2~3245~999....

I'm trying to get the number of Ids in the string, i chose to do this by creating an array holder and using split, its not working though, any thoughts as to why:

var arrIDs = new Array()
arrIDs = sInventoryIDs.split('~');
alert(arrIDs.length);

Is there a regExp way to handle this? Thanks
 
This should work fine:
Code:
var sInventoryIDs = '234~34555~345~2~3245~999';
var arrIDs = sInventoryIDs.split('~');
alert(arrIDs.length);

If that doesn't work, you need to show your code. Copy and paste your real code inside code tags so it's easier to read. The above is tested in IE 6 and worked fine.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top