PDA

View Full Version : Cutting of unwanted text from string


Haddok
09-19-2002, 06:17 PM
Probably an easy one....

I have one input type 'file' [a] in which I receive the file-path & filename.
In another input type 'text' [b] I want the filename only.

Example:
[c:\misc\documents\test.doc] -> [test.doc]

the transfer of values is managed with an 'onChange'.

How do I get rid of the 'c:\misc\documents\' with a script???

adios
09-19-2002, 06:36 PM
<html>
<head>
<title>untitled</title>
</head>
<body>
<form>
<input type="file" size="32"
onchange="v=this.value;filename.value=v.slice(v.lastIndexOf('\\\')+1,v.length)"><br>
<input name="filename" type="text" size="32">
</form>
</body>
</html>

Haddok
09-19-2002, 06:47 PM
Thanxx! :thumbsup: