-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

On 4/19/2010 5:19 PM, André Warnier wrote:
> Ken Bowen wrote:
> ...
> 
>>
>> Long form.  Here's the html for file upload (vanilla):
>>
>> <form name="csvUploadForm" action="csvfileupload" method="post"
>> enctype="multipart/form-data">
>>     File:<input type="file" name="csvfile2upload"><br></br>
>>     <input type="submit" name="Submit" value="Upload CSV File"
>> onclick="uploadCSVFile();return false;">
>> </form>
>>
> Without and before getting to the Java stuff, I do not really understand
> why above you have a button of type "submit", but with an "onClick"
> event triggering a javascript function.
> Either the button should be of type "button" and have an onClick event
> handler, or it should be of type "submit" and not have an event handler.

An exception is the case where you want a page that works both with and
without Javascript enabled: the <input type="submit"> allows the form to
submit in the standard way when no Javascript is present, but allows the
(presumably mind-blowingly fantastic) Javascript alternative to run when
appropriate.

You can't get this behavior from type="button".

> I suspect that by specifying both, you may be generating 2 actions and
> confusing the browser and/or the receiving end.

The "return false;" at the end of the trigger indicates that the event
handler will (duh) return false. When that happens, the browser is
supposed to basically drop the event and not send it to the "default"
handler, which would result in the form being submitted in the
traditional way. This is actually a pretty standard Javascript
implementation.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvMyiUACgkQ9CaO5/Lv0PBb9wCeJZcEXufKdj7RG6MhAz8eIG0p
o3gAoMCjAaMOmzhjs2q8mzlZiwSs7Yx/
=1Z8E
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to