Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>$(document).ready(function() { $('#imgBtnAddNewLineItem').click(function() { $('#container').append('&lt;div&gt;&lt;/div&gt;'); }); }); </code></pre> <p><strong>Update 2</strong></p> <p>Create a normal button like so:</p> <pre><code>&lt;input type="button" id="imgBtnAddNewLineItem" value="Add lineitem" /&gt; </code></pre> <p><strong>Update</strong> ** This is also updated with comments etc.. **</p> <pre><code>//Count the lineItems to make sure they are unique var lineItemCount = 0; //On document ready $(document).ready(function() { //On button click $('#imgBtnAddNewLineItem').click(function(e) { /* ADD THE FOLLOWING LINE TO PREVENT THE POSTBACK P.S. - Make sure you pass -e- to this function... */ e.preventDefault(); //Increase the lineitemcount lineItemCount++; //Add a new lineitem to the container, pass the lineItemCount to make sure getLineItem() can generate a unique lineItem with unique Textbox ids $(container).append(getLineItem(lineItemCount)); }); }); //Create a new DIV with Textboxes function getLineItem(number) { var div = document.createElement('div'); //Give the div a unique id div.setAttribute('id','lineitem_' + number); //pass unique values to the getTextbox() function var t1 = getTextbox('txt_' + number + '_1'); var t2 = getTextbox('txt_' + number + '_2'); var t3 = getTextbox('txt_' + number + '_3'); div.appendChild(t1); div.appendChild(t2); div.appendChild(t3); return div; } //Create a textbox, make sure the id passed to this function is unique... function getTextbox(id) { var textbox = document.createElement('input'); textbox.setAttribute('id',id); textbox.setAttribute('name',id); return textbox; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload