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!

backward slash conversion script

Status
Not open for further replies.

starrwriter

Programmer
Jun 16, 2004
8
US
When used to browse for images, <input type="file"> produces a URL address with backward slashes in the text field. For example -- C:\Windows\Desktop\photo2.jpg.

I need the backward slashes automatically converted to forward slashes before the text field value (URL) is inserted into an image rollover javascript because backward slashes screw up the script (I know why -- escape, etc.) C:/Windows/Desktop/photo2.jpg works just fine in the script.

Isn't there a relatively simple script to do this conversion? I've searched Google, forums and everywhere else I could think of with no luck.
 
sure:
get the value in a variable and wtite this script:
Code:
<script>
Vl="C:\\Windows\\Desktop\\photo2.jpg" // this must be set to the file's value, note the \\ in my code, u wont need them
Vl=Vl.replace(/\\/g,"/")
alert(Vl)
</script>

Known is handfull, Unknown is worldfull
 
Can't use an alert. This is for an offline browser-based WYSIWYG editor. To make a rollover button, the user browses to set the mouseover and mouseout images, then clicks a button to generate AND insert the rollover javascript into the source code of the page under construction.

So I need a script that will change the backward slashes in the browse text field to forward slashes BEFORE the rollover javascript is inserted.
 
that was just a test script, it is just for confirming wether my replace function works...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top