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

I'm trying to do a string replace b

Status
Not open for further replies.

WorkerBeeJ

Programmer
Aug 6, 2002
34
US
I'm trying to do a string replace but am having some trouble. Here's the code:

<script language=&quot;javascript&quot;>
<!--
function openWindow(page) {
var txtDate;
txtDate = document.all(&quot;txtReportMonth&quot;).value;
txtDate = getURLDate(txtDate);
page = page + txtDate;
document.window.open(page,'ReportWindow','width=500,height=500');
}
function getURLDate(txtDate) {
var newDate = txtDate.Replace(/\u002F/g, &quot;_&quot;);
return newDate;
}
//-->
</script>

I believe there's a problem with the line:

var newDate = txtDate.Replace(/\u002F/g, &quot;_&quot;);

I'm trying to replace the slashes in a date with underscores so that I can pass it in a URL.

Anyone know how I can fix this?

Thanks!
 
Try using:

var txtDate = escape(document.all(&quot;txtReportMonth&quot;).value)

...that'll URL-format your txtDate value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top