Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7892419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:51:53+00:00 2026-06-03T06:51:53+00:00

I have a JavaScript function that goes through a list of checked checkboxes and

  • 0

I have a JavaScript function that goes through a list of checked checkboxes and uploads a video file for each checked box. I’m trying to make sure that the videos have been transcoded into a smaller format before I begin the upload process. I use to track the index in the array videos, that have completed the transcode process. I check to be sure that counter is >= id before starting the upload process for a given video. If counter is too low (the file is not yet transcoded) I use setTimout() to call the uploadVideos function again. It never seems to call the uploadVideos function again, because I never see the alert popup a second time.

How can I get this to work?

function uploadVideos(id, videos, selected, boxes) {

        var status = document.getElementById('currentUploadStatus');
        // need to deal with element an array
        var fields = videos[id].split(":", 2);
        var playlist = document.getElementById('playlist');
        var dataString = 'videoId='+ fields[0] + '&playlist=' + escape(playlist.value); 

// need to determine the maxTranscodedId
        var counter = document.getElementById('counter');
        alert('counter: ' + counter.innerHTML + " id: " + id);
        if (counter.innerHTML >= id) {

            id++;
            status.innerHTML = "<b class='status'>Uploading Bout #" + fields[1] + " (" + id + " of " + videos.length + ")</b>";

            $.ajax({  
                type: "GET",  
                url: "floUpload.php",  
                data: dataString,  
                success: function(txt) {
                    if (txt != 'Success') {
                        alert(':' + txt + ':');
                    }

                    if (id < videos.length) {
                        uploadVideos(id, videos, selected, boxes);

                    } else {
                        //re-enable the start button
                        var startButton = document.getElementById('start');
                        startButton.disabled = false;

                        status.innerHTML = "<b class='status'>Upload Complete</b>";
                        alert('Upload Completed');

                    }

                    //deselect the checkbox
                    if (boxes == 1 ) {
                        document.videos.video.checked = false;
                        document.videos.video.style.display = 'none';
                    } else {
                        document.videos.video[selected[id-1]].checked = false;
                        document.videos.video[selected[id-1]].style.display = 'none';
                    } 
                },
                async: true

            }); 



        } else {
            // timer call myself the same way I was called

            status.innerHTML = "<b class='status'>Upload waiting for trancode.</b>";
            var t=setTimeout("uploadVideos(id, videos, selected, boxes)",3000);
            //var t=setTimeout("alert('waking')",3000);
        }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:51:54+00:00Added an answer on June 3, 2026 at 6:51 am

    This is a common error in JS beginners. setTimeout admits either one of two kinds of first parameter:
    a) Text, in which you can put JS code to be evaluated out of scope (so referenced variables may be undefined), not quite helpful.
    b) Function, such as the fix I propose for this, is to replace the line:

    setTimeout("uploadVideos(id, videos, selected, boxes)",3000);
    

    with:

    setTimeout(function(){
        uploadVideos(id, videos, selected, boxes);
    },3000);
    

    As you can see I’m wrapping the function call inside another anonymous function. Why? simply because I need to pass arguments, and otherwise I’d be just calling it, instead of passing as argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript function that I am trying to add to my document,
I have a for loop that goes through each input with class=required , and
I have a javascript function that goes something like this: function doSomething(me) { var
I have a javascript function that calls a generic function to make an ajax
I have a javascript function that accepts a number and performs a mathematical operation
I have a javascript function that checks for a date range. Is there any
I have a javascript function that is being built to animate the collapse of
I have a javascript function that toggles the display for rows in a table.
I have a Javascript function that is called from the onchange method in a
I have a javascript function that changes the innerHtml of a <div> tag to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.