lmchowal
04 May 2011, 08:44 AM
Hi all,
I am new to HTML and javascript coding.
I am havin trouble uploading a file. I have a main form taking inputs from user , validating them and submitting it. Inside the main form i have a file input field allowing user to submit the invoice. My file input field looks like this
<div align="left"
<span id="upload_file_form_element">
<input type="file" name="new_upload_file_0" class="textfield2" size="30" value="Upload Invoice File" onchange="uploadFile();"/>
</span>
</div>.
My main form tag look like this
<form action="MainAction.html" enctype="multipart/form-data" method="post" id="Main" >
<input type="hidden" name="action" id="action" value="create" />
And the submit part
<img src "image.gif" onclick="validform();" name="btn_submit" id="btn_submit" style="cursor:pointer;"> </img>
And my javascript functions are:
function validform(){
if(vaidate())
document.getElementById('Main').submit();
}
function uploadFile() {
{
try {
document.forms[0].action = 'InvoiceUploader.html';
document.forms[0].target = 'invoice_uploader';
document.forms[0].submit();
}
catch{}
}
Now for me the file upload submit part is not working. And from some forums i found out it could be because of the hidden input name, action. I tried to change the hidden input name and id from action to something else , but it still doesn't work. Can someone please help me...
I am new to HTML and javascript coding.
I am havin trouble uploading a file. I have a main form taking inputs from user , validating them and submitting it. Inside the main form i have a file input field allowing user to submit the invoice. My file input field looks like this
<div align="left"
<span id="upload_file_form_element">
<input type="file" name="new_upload_file_0" class="textfield2" size="30" value="Upload Invoice File" onchange="uploadFile();"/>
</span>
</div>.
My main form tag look like this
<form action="MainAction.html" enctype="multipart/form-data" method="post" id="Main" >
<input type="hidden" name="action" id="action" value="create" />
And the submit part
<img src "image.gif" onclick="validform();" name="btn_submit" id="btn_submit" style="cursor:pointer;"> </img>
And my javascript functions are:
function validform(){
if(vaidate())
document.getElementById('Main').submit();
}
function uploadFile() {
{
try {
document.forms[0].action = 'InvoiceUploader.html';
document.forms[0].target = 'invoice_uploader';
document.forms[0].submit();
}
catch{}
}
Now for me the file upload submit part is not working. And from some forums i found out it could be because of the hidden input name, action. I tried to change the hidden input name and id from action to something else , but it still doesn't work. Can someone please help me...