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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:41:51+00:00 2026-06-17T05:41:51+00:00

I am building a form which would have image upload fields, but in way

  • 0

I am building a form which would have image upload fields, but in way that only the first one is visible and the additional fields will show up when a “add another” button is clicked.

What I would like to do is to limit the number of those fields to 3. Below you can see what I have now, but the problem is, the current code does not take the removal of fields into account. So if you add two fields, you’ll get an error like you should, but then if you delete one and try to add it again, you can’t.

I’m a bit lost with jQuery stuff, so any help is very appreciated.

var limit = 3;
$('.add_image').click(function(e){
if($('#back').length < limit) {
                            e.preventDefault();
                            var newElem =  $('<tr class="images-cont"><td><input type="file" name="front" id="front" size="50" /></td><td class="action"><a  title="Delete image" href="#" class="delete" style="background-image:url(\'<?php echo get_admin_url(); ?>/images/no.png\');"><?php _e("Delete"); ?></a></td></tr>');
                            newElem.appendTo('#images-sort');
count++;
} else {
    alert('You cannot add more than 3 images.')   
}
                        })
  • 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-17T05:41:52+00:00Added an answer on June 17, 2026 at 5:41 am
    $('.delete').click(function(){
       $('.images-cont:last').html('<td>A message here</td>');
       count--;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an app in CodeIgniter. I have an invoice form which uses jQuery
I'm building a bunch of forms that have labels and corresponding fields (input element
I'm building an MVC3 application and would like to have a form with a
I have a c# .net 2.0 winforms application which consists basically of one form
I am building a form which uses labels to define the input values (as
I am building an app which requires saving a form whenever user enter the
I'm building a price estimator form, which uses jQuery to manipulate select menus. Basically,
I'm building a form for searching a database inside my application, and I only
I'm building a login form composite component. The page that uses it will pass
I'm building a contact form that appears in a jQuery popup box. When you

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.