By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,625 Members | 1,274 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,625 IT Pros & Developers. It's quick & easy.

<input type="file"> & <input type="submit"> in one action?

P: n/a
Hi,
Does anyone have a solution to use the <input type="file"
id="filechooser"> and the <input type="submit" id="submitbutton"> in 1
button click?

I've already tried to create a javascript function behind the
submitbutton click. In this function i call the filechooser.click()
event and after this i call the functions to activate the progressbar
of the upload.
This doesn't seems to work:(
Has anyone got an idea of what i can do?
Jul 24 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Firstly, please don't multi-post. There's no reason to send the same
message twice, just with a different subject.

Laermans_k wrote:
Does anyone have a solution to use the <input type="file"
id="filechooser"> and the <input type="submit" id="submitbutton"> in 1
button click?


It's not possible to simulate a click on the file upload control when a
user clicks submit, but you may be able to add an onchange event
listener to the file upload control, which automatcially submits when
the user selects a file. However, this would be a very bad user
interface for the following reasons:

1. It changes the expected behaviour of the control
2. If a user selects the wrong file by mistake, it does not give the
user a chance to change their mind before submitting.
3. Using onchange may not allow a user to manually type in a file path,
as the form may submit as soon as they start typing. Although, this
depends upon when the change event is fired by the user agent.

If you plan to go ahead with this regardless, I suggest you ask in a
javascript related group.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Jul 24 '05 #2

P: n/a
Lachlan Hunt wrote:
[...]
3. Using onchange may not allow a user to manually type in a file path,
as the form may submit as soon as they start typing. Although, this
depends upon when the change event is fired by the user agent.
Onchange fires when the control loses focus if its value has changed
since gaining focus.

<URL:http://www.w3.org/TR/html401/interact/scripts.html#adef-onchange>


If you plan to go ahead with this regardless, I suggest you ask in a
javascript related group.


Where they will confirm your opinion that it is a silly idea.
--
Fred
Jul 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.