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

Let me keep slashes

Status
Not open for further replies.

danmat46

Programmer
Nov 13, 2007
23
GB
Hello!
Can't find the answer ....

I am reading in values to an array:

arrVal=new Array("\\server1\c$\Program Files\MyApp\file.xml",\\server2\c$\Hello\file.xml")

But JavaScript keeps removing my slashes so how can I do the above?

Can I set separate variables, like var item1 = "\\server...." and somehow state I wish to keep tha slashes?

Please help!

 
Answer reverse them \ changes to / rookie mistake!
 
I think you can scape them with \

Code:
arrVal=new Array("\\\server1\\c$\\Program Files\\MyApp\\file.xml",\\\\server2\\c$\\Hello\\file.xml")

Cheers,
Dian
 
You need to copy and paste your code in here, not type. If you did that, you're missing an opening quote for the second element of the array.

Other than that, do what Dianecht said and escape the backslashes by doubling the number you have. His example isn't perfect in that respect, so don't copy and paste it into your code (he has the same mistake you do in your example, and he's missing a backslash at the beginning of the first element), but you should be able to correct your code based on it.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top