[thelist] changing link text on-the-fly with JavaScript

Beam sbeam at syxyz.net
Fri Mar 7 09:50:19 CST 2003


>    <a href="somefile.doc">original text</a>
> ...then the user enters "new text" into the text box, selects a file in the
> file upload field, and "saves" that section of the form, the link should
> say... <a href="newfile.doc">new text</a>
> (Well, I guess the link would probably have to point to their local file at
> this point...)
>

something like this? (not tested)

<a href="somefile.doc" id="docLink">original text</a>
<input type="file" onBlur="document.getElementById('docLink').href='file://' +
this.value">
<input type = "text"
onChange="document.getElementById('docLink').firstChild.nodeValue =
this.value">

of course you might have a problem with the link if they have spaces or
special chars in the path/filename...



More information about the thelist mailing list