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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:50:55+00:00 2026-06-01T21:50:55+00:00

i have a javascript function that creates inputfields for uploading images. i have this

  • 0

i have a javascript function that creates inputfields for uploading images.

i have this code:

<script type="text/javascript">
    function add_input(){ 
        var wo = document.getElementById('wo');
        var li = document.createElement('li');

        var input = document.createElement('input');
        input.type = 'file';
        input.name = 'image[]';

    li.appendChild(input);     
    li.appendChild(document.createTextNode(' '));

    var button=document.createElement('input');
        button.type = 'button';
        button.className = 'button small';
        button.onclick=function(){delete_input(this);};
        button.value = 'delete';

    li.appendChild(button);
    wo.appendChild(li);
    }

    function delete_input(feld){ 
    feld.parentNode.parentNode.removeChild(feld.parentNode);
    }
</script>

now my problem is that i would like to create as a maximum 10 inputfields. i never used javascript before and dont know how to limit that.

if there is someone who could tell me how to realize that i would really appreciate. thanks a lot.

  • 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-01T21:50:57+00:00Added an answer on June 1, 2026 at 9:50 pm

    modify your script so that it will have:

    <script type="text/javascript">
    
        var max = 10;
        var current = 0;
    
        function add_input(){ 
            if(current < max){
                current++;
                //...do everything in here for append
            }
        }
    
        function delete_input(feld){ 
            if(current > 0){
                current--;
                feld.parentNode.parentNode.removeChild(feld.parentNode);
            }
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I have one JavaScript that creates rows in a table like this: function
Modern browsers have multi-tab interface, but JavaScript function window.showModalDialog() creates a modal dialog that
I have a javascript function that creates an array and fill it with the
I have a script that I am developing that creates a sliding button type
i have the following function in jQuery and javascript that creates a form element:
I have a function in the code behind of an ASP.NET webpage that creates
I have the following code that creates an object in JavaScript. It uses prototype
I have written a simple Javascript function (curteousy of codecall.net ) that creates a
I have JavaScript class: <html> <head> <script src=MicrosoftAjax.js type=text/javascript></script> <script src=jquery-1.6.4.min.js type=text/javascript></script> </head> <body>
I have a javascript function that calls a web service. The data comeback (I

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.