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!

list to array in Jscript

Status
Not open for further replies.

emmah

Programmer
Sep 26, 2001
4
GB
Hi, I'm sure this is a really easy question but it's driving me crazy at the moment.

how do you transform a comma-separated list into an array in Jscript?

what i want is for

price = Split(pri,",");

to work but it doesn't seem to, i get the error:

Microsoft JScript runtime error '800a138f'

Object expected

is this me? what do i need to do!

thanks for any help

Emma
 

is a good explanation of how the jScript version of split works. It's actually a method of the string object (rather than vbScripts standalone function), and so for any string variable, it can be used like so:

price = pri.split(",");

:)
paul
penny1.gif
penny1.gif
 
i tried that before but i think i've got something wrong, i get

Microsoft JScript runtime error '800a01b6'

Object doesn't support this property or method

 
looks like the MS version of jScript is different for .split() than the regular javaScript version (Surprise!)


Here's a full listing of the methods available with jScript:


Just quickly looking at it, it doesn't look like they even have a function with MS's version that will do what you want. Are you working with client side or server side code there?

paul
penny1.gif
penny1.gif
 
tcha! re-read the basics of arrays and found this...


Array(list)
"list" is a comma-delimited list of values to add to the array.

so all i need to do is...

price = Array(pri);

and it works

:)

thanks for all your help!

Emma
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top