This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Replace function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Replace function" Watch "Replace function" New topic

Replace function

ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76

I am writing a replace function in Javascript to remove the spaces in a filename which is used for file upload. Somehow my replace function is not getting executed.

Here is the code:

<SCRIPT language = JavaScript>

function test ()
var str1 = document.formname.filename.value
str1 = str1.replace(" ", "%20");
and this function is called on the submit button.

Can you please let me know where I am going wrong.

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
you want to do this:

but you might be better off by doing

[ May 25, 2005: Message edited by: Eric Pascarello ]
I agree. Here's the link:
subject: Replace function
It's not a secret anymore!