Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed an Array Output from javascript function
    primarykey
    data
    text
    <p>Chech this <a href="http://jsfiddle.net/7rsLH/" rel="nofollow">fiddle</a> for all the running code i am using</p> <p>i have an array <code>i=[10,20,30,40,50,60,70]</code></p> <p>and i m getting output as</p> <p><code>70:checkbox(checked value 70) </code>.</p> <p>I need all the array to be displayed along with its checkboxes,so that i can check whatever number i want and retrieve the checked ID</p> <p>desired output:</p> <pre><code>70:checkbox(checked value 70) 60:checkbox(checked value 60) 50:checkbox(checked value 50) 40:checkbox(checked value 40) 30:checkbox(checked value 30) 20:checkbox(checked value 20) 10:checkbox(checked value 10) </code></pre> <p>Code for above Fiddle is here: <strong>JS</strong></p> <pre><code> var i=[10,20,30,40,50,60,70]; //$("#add").click(function(){ $(document).ready(function(){ // alert("ff"); var newrow=$('#services .headings').clone().removeClass('headings'); for(var k=0;k&lt;i.length;k++) { var disp = { names: i[k], checks: i[k] } func.call(row,disp); } func(newrow,disp) .insertAfter('#services tr.headings') .show(); }); function func(row,disp) { row.find('.servicenames').text(disp.names); row.find('.servicecheck').data('href',disp.checks); return row; } $("#services").on("click", ".servicecheck",function(){ alert($(this).data('href')); }); </code></pre> <p><strong>html</strong></p> <pre><code> &lt;script src="http://code.jquery.com/jquery-1.10.1.min.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"&gt;&lt;/script&gt; &lt;table id="services"&gt; &lt;tr class="headings" style="display:none"&gt; &lt;td&gt;&lt;span class="servicenames"&gt; service names here&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span class="servicecheck" data-href=""&gt;&lt;input type="checkbox" id="servicecheck" name="servicecheck"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </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.
 

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