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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:52:39+00:00 2026-05-31T20:52:39+00:00

I have created a add input field function which is working fine. I would

  • 0

I have created a add input field function which is working fine. I would like add many input field on basis of input field number.I just start unfortunately couldn’t find a proper result for that.
here is my JQ code

$(document).ready(function() {
    var scntDiv = $('#add_words');
    var wordscount = 1;
    var i = $('.line').size() + 1;

    $('#add').click(function() {
        var v = $("#inputs").val();
        alert(v);
        wordscount++;
        $('<div class="line">Word is ' + wordscount + '<input type="text" value="' + wordscount + '" /><a class="remScnt" href="#">Remove</a></div>').appendTo(scntDiv);
        i++;
        return false;
    });

    //    Remove button
    $('#add_words').on('click', '.remScnt', function() {
        if (i > 1) {
            $(this).parent().remove();
            i--;
        }
        return false;
    });
});

and HTML code also

<select id="inputs" style="width:60px;">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>                      
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
</select>
<a id="add" href="#">Add</a>
<div id="add_words"></div>

Actually I need to add input filed on the basis of how much is we select in the id="inputs.

  • 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-31T20:52:40+00:00Added an answer on May 31, 2026 at 8:52 pm

    Like this:

    $(document).ready(function() {
        var scntDiv = $('#add_words');
        var wordscount = 1;
        var i = $('.line').size() + 1;
    
        $('#add').click(function() {
            var inputFields = parseInt($('#inputs').val());
            for (var n = i; n < inputFields; ++ n){
                wordscount++;
                $('<div class="line">Word is ' + wordscount + '<input type="text" value="' + wordscount + '" /><a class="remScnt" href="#">Remove</a></div>').appendTo(scntDiv);
                i++;
            }  
            return false;
        });
    
        //    Remove button
        $('#add_words').on('click', '.remScnt', function() {
            if (i > 1) {
                $(this).parent().remove();
                i--;
            }
            return false;
        });
    });
    

    See it in action here:
    http://jsfiddle.net/zLG7c/6/

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

Sidebar

Related Questions

I have just created add input field with <a id=add>Add</a> link button which is
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have just created a GIT on a folder. I now want to add
I have created an Excel 2003 add-in that uses the CLR 2.0 and this
I have created a CustomAction feature to add a button to the Actions menu
I have created a foreign key (in SQL Server) by: alter table company add
I have created a WebPart. When I add the WebPart to a page I
I am attempting to add some entities that I have created. When I try
I have a simple GtkStatusBar created with glade,and want to add a simple message
I have a computed column created with the following line: alter table tbPedidos add

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.