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

Chris Marsh chris at ecleanuk.com
Fri Mar 7 09:47:01 CST 2003

> Sarah Sweeney wrote:
> > I have a page with a rather complicated form. Part of this
> form can be
> > "saved" (really it will just be  hidden, using the CSS "display:
> > none;") separately from the rest. What I'd like is for the value of
> > the text box and file upload field in this part of the form
> to be used
> > to change a link. So if the link is like this at first...
> >   <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...)
> from what I understand about what you want, I'm not certain
> it's possible, for security reasons.

You can't *write* a value for an input of type "file", but you *can*
read it. If you do what Sarah is suggesting, then you would end up with
a link to a file on the local machine; locally. This presents no
security hole, but is also of very little use as you can view files on
your own machine through windows explorer, apart from anything else. The
only reason I have ever done this in the past is to preview images which
are about to be uploaded.

> file upload boxes are generally a don't-touch area for
> JavaScript because if it was possible to manipulate them,
> then a sneaky webmaster could grab a copy of your files
> without you knowing.
> I think you have a tricky time ahead of you if you require
> this to be done in teh backend.

I would personally do the whole thing on the server. You may lose a
little time in request/responses, but IMHO you more than make up for
this with a much more accessible and robust application.


Chris Marsh

More information about the thelist mailing list