Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery arrays not working
    primarykey
    data
    text
    <p>I need to have a tool that builds dynamic form elements. I wanted to build a multidimensional array to add the elements and then store the attributes of this element. </p> <pre><code>dType[100] = $('&lt;input&gt;').attr({'class':'inp'}),'type:input'; // 2 elements not working? </code></pre> <p>Trying to retreive via:</p> <p><code>dType[100][2]</code> to get the item needed, but not working.</p> <pre><code> $('.addItem').click(function(){ var dType = []; dType[100] = $('&lt;input&gt;').attr({'class':'inp'}), 'dfdf'; dType[200] = $('&lt;textarea&gt;').attr({'class':'inp', rows: 3, cols: 25}); dType[300] = $('&lt;select&gt;').attr({'class':'inp'}); dType[400] = $('&lt;input type="radio" value="one"&gt;&lt;br&gt;&lt;input name="rOptions" type="radio" value="two"&gt;'); dType[500] = $('&lt;input type="checkbox" value="one"&gt;&lt;br&gt;&lt;input name="rOptions" type="checkbox" value="two"&gt;'); alert(dType[900][2]); var dTypeNum = $(this).attr('id'); var numDivs = $('.InputItem').length; var newNumDivs = new Number(numDivs + 1); var newDiv = 'inpDiv' + newNumDivs; var newId = 'inp' + newNumDivs; var newElem = '#' + 'inpDiv' + newNumDivs; $('&lt;div&gt;').attr({'id':newDiv, 'class':'InputItem'}).appendTo('.container'); $('&lt;label&gt;').attr({id: 'tt'+ newNumDivs}).css('display','block').appendTo('#' + newDiv).text('Label'); $(dType[dTypeNum][1]).attr({'id':newId, 'name': 'FD' + newNumDivs} ).appendTo('#' + newDiv); $(newElem).draggable( { containment: '.container',cursor: 'move',snap: '.container',stop: handleDragStop }); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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