I’m making a form,with a file input,and the input should be hidden,so the action of click is done by another button.
I found that I can submit the form after directly clicked the file input,
but it didn’t work using the indirect button. ? ?
Can anybody solve this problem?
Thank you!
CODE as follows:
[CODE]<HTML>
<HEAD>
<TITLE>javascript</TITLE>
<SCRIPT LANGUAGE=javascript>
function checkit(args)
{
if(args.sendText.value==”)
{
alert(“no file selected”); return false;
}
else return true;
}
</SCRIPT>
</HEAD>
<BODY bgcolor=”#FFFFFF” >
<form name=form action=1.html>
<input type=”file” name=”sendText” onclick=”click();”>
<input type=”submit” name=”submit” onclick=”return checkit(this.form);” value=”submit the form directly”><br><br>
<input type=”button” name=”check” onclick=”document.form.sendText.click();” value=”open the browse file dialogue indirectly”>
<input type=”button” name=”check2″ onclick=”document.form.submit.click();” value=”submit the form indirectly”>
</form>
<pre>
result:
1.if click the “browse…” button,both direct and indirect submit work well,
2.once the “open the browse file dialogue indirectly” was clicked, no way to submit the post,</pre>
</BODY>
</HTML>
CODE]