开发者

Javascript PHP var array puts double quotes in

I can't work this one out...

I have a var called data which consists of exactly this..

"12-9-2011","13-9-2011","14-9-2011","15-9-2011","16-9-2011"

including the quotes

but when i come to use the javascript command unavailableDates = [data];

it adds more quotes on either end... how can i stop this..

it makes unavail开发者_如何学运维ableDates equal ""12-9-2011","13-9-2011"...15-9-2011","16-9-2011","

you see with quotes on the ends...

Any way i can stop this ?

Thanks

Lee


If you use a string in a literal array it will just be an array with a single string, it won't evaluate the string.

Split the string into an array instead:

unavailableDates = data.substr(1, data.length - 2).split('","');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜