Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
4.20/5 (2 votes)
See more:
I am having a problem where the "\\" and "\" are getting removed from my file path

C#
<span  önClick=\"playRec('" + path + "');\">Play</span>

function playRec(val) {
     alert(val);
 }


the val is showing an incorrect filepath.
Posted
Comments
CBadger 24-Apr-14 7:32am    
What does path show?
So in debug what is the actual value op path and what gets passed into the query then to what does it change to?
Linkz_G 24-Apr-14 8:06am    
this is how the path shows:
\\cci-netapp\Recordings02\archive\EuroChance\201204\20120417\20120417_184458_004511_123456789.wav

but in my function playrec the val is:
\cci-netappRecordings02ArchiveEuroChance3113110431104_145406_004534_123456789.wav
Shah Parth P 24-Apr-14 7:45am    
you can fix the path of a file by using static string.
and keep the file name dynamic only.
Take file name form the user if possible.
or specify how you want to call it???

Try using a regex to keep escape characters

C#
var val = $(this).attr('val').replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\\\$&")


Although in your case you can also try and use the filter[§] settings
with all elements selection
C#
var value = this.value;
$select.find('option').filter(function() {
  return this.value == value;
}).show();
 
Share this answer
 
v3
this fixed the issue:

path = path.replace(/[\\]/g, "\\\\");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900