Input Number to Add more Inputs JQuery -


I have to keep a form input, which will enter a number and click the button next to it so that it is "add"

  • Enter the number
  • Click the Go Button or whatever
  • Output on the same page which is the number of inputs (creates new inputs)

    I have tried to do that which only gives one feature at a time:

      $ (function () {var i = $ ('Input' ). How many inputs on size () + 1; // document Boots are present and add 1 for add command to work with $ 1 ('a # add'). (Function () {// when you add link $ ('& lt; p & gt; & lt; input type = "Text" value = "'+ i +'" /></p>').appendTo('body '); // Click on attachment A new input (add) in the document // if After you click on the append IO ++; // I will be i = 3 if you click again if I have input inside a form, then i will be i = 4}); $ (' A # remove '). Click (function () {// Previous As such, when you click the rim ov link if (i & gt; 1) {// If you have at least 1 input on form $ ('Input: last'). Remove (); // Remove the previous input I--; // If I decrease by 1 then i = 3, i-after, i i = 2}}); $ ('A.reset') Click (function () {when (i & gt; 2) {// when there is more than 1 input on your page $ ('input: last'). Remove (); // Delete the input i--; }}); }); & Lt; A href = "#" id = "add" & gt; Add & lt; / A & gt; & Lt; A href = "#" id = "remove" & gt; Remove & lt; / A & gt; & Lt; Input type = "text" value = "1" />    

    something like that?

      & lt; Script & gt; $ (Document) .ready (function () {$ ('# addButton') Click (function () {var count = parseInt ($ ('# quantity'). Val ()); var newHTML = []; (Var i = 0; i  

    Whatever content you want $ $ ('# sandbox'). Html (newHTML.join (''));});}); & Lt; / Script & gt; & Lt; Input type = "text" id = "volume" value = "" /> & Lt; Input type = "button" id = "addButton" value = "add" /> & Lt; Div id = "sandbox" & gt; & Lt; / Div & gt;

  • Comments