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

"Access Denied" submitting form with Javascript?

P: n/a
The following javascript code generates an "Access denied" error at the
indicated line.

This sample should allow the user to click "Browse" and choose a file. Once
the user has selected a file the form is automatically submitted. I'm trying
to avoid having seperate browse and submit actions.

Can someone explain why I'm getting the error and how I can accomplish this
task?

Thx!

<html>
<head></head>

<body>

<form name="form1" id="form1" method="post" action="test.htm">
<input type="button" value="Browse" onclick="return vlu();">
</form>

<form name="form2" id="form2" method="post" action="test.htm"
style="display:none;">
<input type="file" name="file1" id="file1">
</form>

<script language="javascript"> <!--
function vlu() {
form2.file1.click();
if (form2.file1.value != "") {
form2.submit(); //*** ERROR HERE
}
}
//-->
</script>
</body>
</html>


Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Correct, the type="file" input element gives little access, reason why is
security, so, chances are, access is denied to many of its objects as well
as .click() method, run a For In on it maybe, to see which you can access,
but most do not give access due to security.

Danny

On Sun, 05 Jun 2005 13:03:39 -0700, Noozer <do*******@me.here> wrote:

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #2

P: n/a
Lee
Noozer said:

The following javascript code generates an "Access denied" error at the
indicated line.

This sample should allow the user to click "Browse" and choose a file. Once
the user has selected a file the form is automatically submitted. I'm trying
to avoid having seperate browse and submit actions.


Besides the security issue, what if I just accidentally release
the mouse button over the wrong file? You don't want to make it
too easy to make a potentially serious mistake.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.