Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts

    adding hidden div causes no page reload

    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
    Code:
    
    <!-- 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

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

    my javascript looks like this


    Code:
    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?
    Last edited by durangod; 11-06-2012 at 10:48 PM.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,642
    Thanks
    6
    Thanked 1,005 Times in 978 Posts
    Try the return values without brackets: return false;

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts
    nope same result, does not refresh at all even with removing the brackets

  • #4
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    why are there brackets in the input name??

  • #5
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts
    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

    Code:
    
    <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.
    Last edited by durangod; 11-06-2012 at 05:27 PM.

  • #6
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,381
    Thanks
    264
    Thanked 32 Times in 31 Posts
    Quote Originally Posted by DanInMa View Post
    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?
    Last edited by durangod; 11-06-2012 at 05:20 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •