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 9203423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:28:15+00:00 2026-06-17T23:28:15+00:00

Below I have a file input and 2 javascript functions which control the start

  • 0

Below I have a file input and 2 javascript functions which control the start and stop of the file uploads.

FILE INPUT:

var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target_image' onsubmit='return imageClickHandler(this);' class='imageuploadform' >" +
    "<p class='imagef1_upload_form'><label>" +
    "Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><br/><label class='imagelbl'>" +
    "<input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /></label>" +
    "<label><input type='button' name='imageClear' class='imageClear' value='Clear File'/></label>" +
    "<p class='imagef1_upload_process'>Loading...<br/><img src='Images/loader.gif' /></p>" +
    "<input type='hidden' class='numimage' name='numimage' value='" + GetFormImageCount() + "' />" +
    "</p><p class='imagef1_cancel' align='center'><label>" +
    "<input type='reset' name='imageCancel' class='imageCancel' value='Cancel' /></label>" +
    "</p><p class='imagemsg'></p><p class='listImage'></p>" +
    "<iframe class='upload_target_image' name='upload_target_image' src='/' style='width:0px;height:0px;border:0px;solid;#fff;'></iframe></form>");

START UPLOADING FUNCTION:

    var sourceImageForm;

    function htmlEncode(value) { return $('<div/>').text(value).html(); }


function startImageUpload(imageuploadform){

  $(imageuploadform).find('.imagef1_upload_process').css('visibility','visible');
  $(imageuploadform).find('.imagef1_upload_form').css('visibility','hidden');
  $(imageuploadform).find('.imagemsg').css('visibility','hidden');
  sourceImageForm = imageuploadform;


      return true;
}

STOP UPLOAD FUNCTION:

function stopImageUpload(success, imageID, imagefilename){

      var result = '';
      imagecounter++;

      if (success == 1){
         result = '<span class="imagemsg'+imagecounter+'">The file was uploaded successfully</span>';   
            $('.listImage').eq(window.lastUploadImageIndex).append('<input type="hidden" name="imgid[]" id="'+imageID+'" value="' + imageID + '" />');
            $('.listImage').eq(window.lastUploadImageIndex).append('<div>' + htmlEncode(imagefilename) + '<button type="button" class="deletefileimage" data-imageID="'+imageID+'"  data-image_file_name="' + imagefilename + '">Remove</button><br/><hr/></div>');
         }


      $(sourceImageForm).find('.imagef1_upload_process').css('visibility','hidden');
      $(sourceImageForm).find('.imagemsg').html(result);
      $(sourceImageForm).find('.imagemsg').css('visibility','visible'); 
      $(sourceImageForm).find(".fileImage").replaceWith("<input type='file' class='fileImage' name='fileImage' />");
      $(sourceImageForm).find('.imagef1_upload_form').css('visibility','visible');



      return true;   
}

Now what is happening is that when the user uploads a file, the text input and buttons re hidden and the loading bar will be displayed underneath where the file input and buttons were, then when the uploading is finished then the success message is displayed underneath where the loading bar was. The problem with all this though is that it takes up too much space.

What I want to do is the following:

  1. User will use the file input to upload file uing the file input and upload button
  2. When uploading the loading bar will replace the file input and buttons so that it is placed where the file input and buttons were.
  3. When user finishes uploading, the loading bar is replaced with the file input and the original buttons and the success mesage is displayed underneath and underneath the success message is where it displays the uploaded file names and Remove button for each file name
  4. Repeat process for next uploading file

My question is how to achieve the above points? At the moment my code is doing this below:

Below is the file input:

enter image description here

Below is where the loading bar appears when the user is uploading a file, it hides the rest of the elements to just show the loading bar and the cancel button but this is displayed underneath where the file input and buttons was:

enter image description here

Below is where it displays the success message and file name with remove button, but this is displayed underneath the the loading bar would have been. As you can see it is too big of a gap in between and I want to narrow it, so instead of hide and show, I prefer a replace with.

enter image description here

  • 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-17T23:28:16+00:00Added an answer on June 17, 2026 at 11:28 pm

    Use

    .css('display','none');
    

    Instead of visibility:hidden

    When you hide something by setting visibility to hidden, it still takes up space in your layout. If you want it to behave like it isn’t there at all, you need to set display instead. To bring it back, just set display to block or whatever it was before you hid it. Or even better, just use jQuery’s .hide() and .show() functions (which means you don’t have to worry about whether it was originally block or inline).

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

Sidebar

Related Questions

in the QandATable.php I have a form below which contains a file input and
I have a form stored in a javascript variable below: var $fileImage = $(<form
I have a form and 2 javascript functions below but I am getting 2
I have a java file Test.java (below) which uses Guava's HashMultiMap (downloaded from http://code.google.com/p/guava-libraries/
i have coded a header file which contains a input textbox for search.this header
I have an HTML form with an input field to upload a file. I
I have a HTML form ( upload.htm ) with a HTML file upload control
I have file input fields in a group like below. I'd like all of
I have a JavaScript file which has a function that I reference. When I
hello i have the html code below <form> <input type=text id=filepathz size=40 placeholder=Spot your

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.