IE5.
This string replacement function only replaces the first instance of an asterisk with a backslash instead of all asterisks in the string. Anyone have ideas as to why it's not replacing all the *?
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function sendPath(pathName){
var newpath = pathName.replace("*","\\"
window.opener.document.forms[0].elements[0].value=newpath;
self.close;
}
//-->;
Background if you will find it helpful:
I am passing a file path in a variable to a javascript function, but I couldn't make the backslashes (\) pass in the string. I decided instead to replace the slashes with asterisks before sending the variable, and now the asterisks get passed inside the variable, so that the file path 'C:\Inetpub\ looks like this 'C:*Inetpub* when it arrives in the javascript function. So far so good. Then I try to replace all of the asterisks with backslashes again so that it will look like a normal file path and I can pass the value to a text box on the parent page. But instead of replacing all asterisks, it only replaces the first one, like this: 'C:\Inetpub*
thanks
thessa
This string replacement function only replaces the first instance of an asterisk with a backslash instead of all asterisks in the string. Anyone have ideas as to why it's not replacing all the *?
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function sendPath(pathName){
var newpath = pathName.replace("*","\\"
window.opener.document.forms[0].elements[0].value=newpath;
self.close;
}
//-->;
Background if you will find it helpful:
I am passing a file path in a variable to a javascript function, but I couldn't make the backslashes (\) pass in the string. I decided instead to replace the slashes with asterisks before sending the variable, and now the asterisks get passed inside the variable, so that the file path 'C:\Inetpub\ looks like this 'C:*Inetpub* when it arrives in the javascript function. So far so good. Then I try to replace all of the asterisks with backslashes again so that it will look like a normal file path and I can pass the value to a text box on the parent page. But instead of replacing all asterisks, it only replaces the first one, like this: 'C:\Inetpub*
thanks
thessa