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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:34:11+00:00 2026-05-20T21:34:11+00:00

We are using following code to append more input element on text change: $(document).ready(function()

  • 0

We are using following code to append more input element on text change:

$(document).ready(function() {
$('#instal').change(function() {
    var instalval = parseInt($(this).val());
    if(instalval != '') {
    for( i = 0; i < instalval; i++) {
        $('#fields').append(' <li class="inputs clearfix"><input type="text" class="small" size="30" name="date" placeholder="Date" /> <input type="text" class="small" size="30" name="amount" placeholder="Amount" /> <span title="Remove this" class="ui-icon ui-icon-closethick closefield"></span> </li>');
    }
    }  
});
$('.closefield').live('click', function() {
$(this).parent().remove();
});
});

We are using html5 input type=”number” for value but so it adds 6 elements if we selects 6 and after that if we selects 12 it adds 12 to last added 6 elements so totals elements would be 18 not 12 (on selection of 12), so how can we fix our code to achieve this, and what if we select 6 again after selecting 12, i hope this makes sense. thanks.

Even if you could help how can we post it to mysql using php?

  • 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-20T21:34:12+00:00Added an answer on May 20, 2026 at 9:34 pm

    You could put an if statement in the beginning of the callback that checks if the #fields element’s children have the class inputs. If it does, then remove them.

    $(document).ready(function() {
    $('#instal').change(function() {
        if($('#fields').children().hasClass('inputs')) {
            $('.inputs').remove();
        }
        var instalval = parseInt($(this).val());
        if(instalval != '') {
            for( i = 0; i < instalval; i++) {
                $('#fields').append(' <li class="inputs clearfix"><input type="text" class="small" size="30" name="date" placeholder="Date" /> <input type="text" class="small" size="30" name="amount" placeholder="Amount" /> <span title="Remove this" class="ui-icon ui-icon-closethick closefield"></span> </li>');
                $(function() {
                     $( ".small" ).datepicker({ minDate: "+" + i.toString() + "M" });
                });
            }
        }  
    });
    
    $('.closefield').live('click', function() {
        $(this).parent().remove();
     });
    

    This is for the jQuery UI datepicker:

    $(function() {
        $( ".date" ).datepicker();
    });
    

    This is for fixing the range of dates:

    $(function() {
        $( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to create an image element, load it, then append
I'm using the following code to send push notifications to the user... document.triggerNotification =
I'm using the following code to pass to my javascript code sb.Append(start: new Date(
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
I'm using the following code to query a database from my jsp, but I'd
I've been using the following code to open Office Documents, PDF, etc. on my
I am using following PHP code to connect to MS Access database: $odb_conn =
I am currently using the following code to create a web request: Dim myRequest
I'm using the following code within the JCProperty class to retrieve data from a
I'm using the following code, using the SharpZipLib library, to add files to a

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.