[thelist] JavaScript fun
jeff
jeff at members.evolt.org
Sat Apr 14 00:58:11 CDT 2001
Jim,
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Jim McNulty
:
: First, I think Anthony is right and it
: should be done server side.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Agreed.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: If you must do it client side, [...]
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... then you wouldn't be uploading files cause you gotta know the name of
the file on the server so you can make sure it gets the same name.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Then, on the "uploadfile" field, put in
: an onChange event handler.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
little known fact: the onChange event handler on a file upload field does
not work. instead, you'll be better off setting the value when the form is
submitted via the onSubmit event handler.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: function getName()
: {
: // parse the uploadfile value for the name
: myRegExp = /[^/\\]*\..*/gi;
: document.mainForm.filename.value =
: myRegExp.exec(document.mainForm.uploadfile.value);
: }
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
what's wrong with good old strings functions?
function getName()
{
// parse the uploadfile value for the name
form = document.mainForm;
fullpath = form.uploadfile.value;
filename = fullpath.substring(fullpath.lastIndexOf('\\') + 1);
document.mainForm.filename.value = filename;
}
good luck,
.jeff
name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:jeff at members.evolt.org
More information about the thelist
mailing list