473,473 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Replace function not working

36 New Member
In my project,iam passing file path as a parameter to a javascript function.

On replacing the separator with escape character, iam passing this parameter to another function that is called in my previous function.
But in my second function, iam getting the blank spaces without the separator.

Expand|Select|Wrap|Line Numbers
  1. function linkFolderHTML(isTextLink) 
  2.   var docW = "";
  3.  
  4.  
  5.  
  6.     var str =this.hreference; //PATH "E:\XX\test";
  7.     var xy = str.replace('\\','\\\\');
  8.  
  9.   if (this.hreference) 
  10.   {
  11.  
  12.     if (USEFRAMES)
  13.  
  14.      // docW = docW + "<a href='" + this.hreference + "' TARGET=\"_self\" "
  15.             docW = docW + "<a href='javascript:ajaxDisplay(\""+xy+"\",\""+this.getID()+"\")' TARGET=\"_self\" "
  16.     else
  17.     //  docW = docW + "<a href='" + this.hreference + "' TARGET=\"_self\" "
  18.             docW = docW + "<a href='javascript:ajaxDisplay(\""+xy+"\",\""+this.getID()+"\");' TARGET=\"_self\" "
  19.  
  20.     if (isTextLink) {
  21.         docW += "id=\"itemTextLink"+this.id+"\" ";
  22.     }
  23.  
  24.     docW = docW + ">"
  25.   } 
  26.   else 
  27.     docW = docW + "<a>" 
  28.   return docW;
  29.  
  30.  
  31.  
  32.  function ajaxDisplay(path,id)
  33. {
  34.   alert(path); //iam getting "E:XX test"
  35.   searchReq.open('GET','../jsppages/displaylist.jsp?path='+pathx);
  36.   // searchReq.open('GET','../jsppages/treeview.jsp?mode=display&path='+pathx);
  37.     searchReq.onreadystatechange = function()
  38.             {
  39.               DisplayReply(divid);
  40.             };
  41.         searchReq.send(null);
  42.  
  43. }
  44.  
Attached Files
File Type: txt javascript.txt (1.2 KB, 419 views)
Aug 24 '11 #1
1 1599
Dormilich
8,658 Recognized Expert Moderator Expert
if this.hreference is assigned "E:\XX\test"; then the replace statement won’t work because in str the escaping is already executed, i.e. str = "E:XX est";. use encodeURIComponent() to prepare the string for URL transmission.
Aug 24 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Venkat | last post by:
Did anyone used String.replace function, its not working for me can someone help me on the same.
10
by: pembed2003 | last post by:
Hi all, I asked this question in the C group but no one seems to be interested in answering it. :-( Basically, I wrote a search and replace function so I can do: char source = "abcd?1234?x";...
2
by: Sharon | last post by:
I've had an Access 2000 app running successfully for many months on both Windows XP and Windows 2000. Recently when my Windows 2000 users call a particular report, they get first a dialog...
9
by: Not Me | last post by:
Hi, I'm having bother with the replace function in access 2002, a while back I remember not being able to get it to work... then suddenly the next time I tried it did work. Now it doesn't...
3
by: Dave | last post by:
I have an Access 2K application that is distributed to about a dozen users (all with identical NT environments and identical Access versions, object libraries and service packs). I am using the VBA...
3
by: Andy Sutorius | last post by:
Hi, I read the thread (2/16/05) regarding a replace function in C# however it didn't answer my question. I have a string which is building an insert sql statement and I would like to replace...
4
by: Cor | last post by:
Hi Newsgroup, I have given an answer in this newsgroup about a "Replace". There came an answer on that I did not understand, so I have done some tests. I got the idea that someone said,...
4
by: Lauren Wilson | last post by:
Hi folks, We have a need to replace sub strings in certain message text. We use the Office Assistant to display help and often use the imbedded formatting commands. Those of you who have used...
8
by: Warren Moxley | last post by:
Hi there, i've been searching for a C String search and replace function. I need to find all occurrences of " " in a char* array, and replace them with another char, I know how to do this in...
1
by: seanmatthewwalsh | last post by:
Hi I have a website that uses an Access 2003 database. I have controls on my pages that are bound to SqlDataSources that pull data from this database. In a couple of them, I need to use the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.