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

  • Home
  • SEARCH
  • 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 3443548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:48:18+00:00 2026-05-18T08:48:18+00:00

Im trying to implement some code i found on a website which duplicates a

  • 0

Im trying to implement some code i found on a website which duplicates a file field when you click a href link, the code is pretty much exactly the same from the site, yet its not working at all.

Could someone have a look and let me know where im going wrong.

The complete code is as follows:

JavaScript:

<script>
$(
function(){
    var jAddNewUpload = $( "#add-file-upload" );

    jAddNewUpload
        .attr( "href", "javascript:void( 0 )" )
        .click(
            function( objEvent ){
                AddNewUpload();

                objEvent.preventDefault();
                return( false );
            }
        );
}
);

function AddNewUpload(){
    var jFilesContainer = $( "mpfiles" );
    var jUploadTemplate = $( "#element-templates div.row" );
    var jUpload = jUploadTemplate.clone();
    var strNewHTML = jUpload.html();
    var intNewFileCount = (jFilesContainer.find( "div.row" ).length + 1);

    jUpload.attr( "id", ("file" + intNewFileCount) );

    strNewHTML = strNewHTML
        .replace(
            new RegExp( "::FIELD3::", "i" ), ("mpfile[]")
        );

    jUpload.html( strNewHTML );

    jFilesContainer.append( jUpload );
}
</script>

HTML:

<div id="mpfiles">
    <div class="row">
        <label>Files:</label>
        <div class="files-box">
            <div class="file sub-file">
                <input class="file-input-area" name="mpfile[]" type="file" size="32" value="" />
                <input readonly="readonly" class="text" type="text" value="click to upload" />
                <a href="#" class="button">view</a>
            </div>
        </div>
    </div>
</div>

<div id="element-templates" style="display: none;">
    <div class="row">
        <label>Files:</label>
        <div class="files-box">
            <div class="file sub-file">
                <input class="file-input-area" type="file" name="::FIELD3::" size="32" value="" />
                <input readonly="readonly" class="text" type="text" value="click to upload" />
                <a href="#" class="button">view</a>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <label>&nbsp;</label>
    <a href="" id="add-file-upload">Upload another file</a>
</div>

The website where i got the code from is here http://www.bennadel.com/blog/1375-Ask-Ben-Dynamically-Adding-File-Upload-Fields-To-A-Form-Using-jQuery.htm

  • 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-05-18T08:48:18+00:00Added an answer on May 18, 2026 at 8:48 am
    function AddNewUpload(){ var jFilesContainer = $( "mpfiles" );
    

    You need a # before mpfiles … like this:

    function AddNewUpload(){ var jFilesContainer = $( "#mpfiles" );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to implement unit testing and currently have some code that does
I'm trying to implement single sign-on for a web portal. I've written some code
I'm trying to implement some retry logic if there is an exception in my
I'm trying to implement some basic linear algebra operations and one of these operations
I'm trying to implement the WMD editor used on StackOverflow to create some basic
Here are the specs that I'm trying to implement in a nutshell: 1) Some
Am trying to implement a generic way for reading sections from a config file.
I want to implement some image-processing algorithms which are intended to run on a
Any idea how I express 'implements' in UML? I'm trying to write some actionscript
All I am currently trying implement something along the lines of dim l_stuff as

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.