...

View Full Version : Resolved adding hidden div causes no page reload



durangod
11-06-2012, 04:45 PM
Hi i have a file upload for videos that works fine normally, i decided to add some text on button click to let them know that the process is running.

Without the javascript hidden div, the video uploads and when its done the page refreshes and the vid is there.

However with the hidden div the video uploads but the page never refreshes, it just sits there as if it is still uploading. My text video takes 5:30 to upload and with the hidden div i can wait 11 min and still processing, i hit the browser x and the vid is there.

My question is, is there any reason add this javascript would cause this, because without it, it runs fine.

Here is what i added:


i put this inside the form element just before the close form tag




<!-- this is the div to display the status of the upload process -->
<div align="center" id="vidstatus" style="display:none;font-size:9px;font-weight:bold;color:#FF3300;width:550px;">
Video Upload In Progress ... Please wait!... The screen will refresh when upload complete...
<br /> <br />
</div>






here is the input




<input type="file" id="fileupload" name="fuploadvid[]" size="20" class="inputf"></




my javascript looks like this





var fval = document.FrmPicture.fileupload.value;

if (!fval)
{
alert("You must select an upload file!");
document.FrmPicture.fileupload.focus();
return (false);
}else{
document.getElementById("vidstatus").style.display = "block";
return (true);
}




so if i remove the div and the javascript the upload process works fine. What in those two items would cause it to hang?

VIPStephan
11-06-2012, 04:50 PM
Try the return values without brackets: return false;

durangod
11-06-2012, 05:00 PM
nope same result, does not refresh at all even with removing the brackets

DanInMa
11-06-2012, 05:15 PM
why are there brackets in the input name??

durangod
11-06-2012, 05:15 PM
ok i got it but i dont understand why this is..

i got it to work by seperating it into its own function. I put the normal function to verify data on the form tab using onsubmit and then i added the onclick to the submit button and called the new function seperately and it works. Why i dont know ?


here is what i did..

javascript here





<script type="text/javascript">

function verifydat()
{

if (document.FrmPicture.vidname.value.length < 4)
{
alert("You must enter at least 4 char as the video title!");
document.FrmPicture.vidname.focus();
return (false);
}


if(document.FrmPicture.vidname.value == 'Title' || document.FrmPicture.vidname.value == 'title')
{
alert("The title field is a required field - it cannot be called title - use a different title name!");
document.FrmPicture.vidname.focus();
return (false);
}

var fval = document.FrmPicture.fileupload.value;

if (!fval)
{
alert("You must select an upload file!");
document.FrmPicture.fileupload.focus();
return (false);
}

return (true);

}//end function verifydat


function showhdiv()
{
var fval = document.FrmPicture.fileupload.value;

if (fval)
{
document.getElementById("vidstatus").style.display = "block";
}

}//close function showhdiv

</script>






the verifydat is called onsubmit form
the showhdiv is called on submit button click

Here is my concern, the showhdiv is either on or off it does not check to see if the form validation is true, so it could happen that the form could be in error but yet the uploading message still appears. And im not sure what i can do to make sure the showhdiv does one execute until the form validation is true..

UPDATE i just did a test and it does appear that the onsubmit takes presedence over the onclick so i might be ok.

durangod
11-06-2012, 05:18 PM
why are there brackets in the input name??

Because its an array, i am planning one day to do a multiple upload routine and so i coded it for that now in advance. But i would think it should not affect it, its checking for value not what kind of value right? So the only way a input file tag would have value is if there is a file in there, you cant type in the field. Am i right?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum