Note that there are some explanatory texts on larger screens.

plurals
  1. PONot selector (not sure if I'm doing it properly)
    primarykey
    data
    text
    <p>I've been doing this thing for a couple of days and I can't seem to find the right way to do this. What I wanted it when the user unchecks the checkbox it should submit the Id of the checkbox then delete it to the table.</p> <p>//JS</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $('#list-tbl tr').each(function(){ var $this = $(this); var ID = $(this).attr("id").replace("tr",""); var user_id = $('#user_id').val(); var read = $('#read'+ID).val(); var add = $('#add'+ID).val(); var approve = $('#approve'+ID).val(); $('input[type=checkbox]', $this).change(function(){ if($('.read'+ID, $this).is(':checked')){ $('input[type=checkbox]', $this).prop('disabled',true); $.ajax({ type: "POST", url: "&lt;?= base_url('admin/update/read')?&gt;", data: "read="+ read + "&amp;user_id=" + user_id, success: function(){ $('form#submit').hide(); alert("Permission added"); $('div.success').fadeIn(); } }); $(this).prop('disabled',false); } else if($('.add'+ID, $this).is(':unchecked')) { $('.read', $this).prop('disabled', true); $.ajax({ alert("FU"); } }); $(this).prop('disabled', false); } else if($('.add'+ID, $this).is(':checked')) { $('.read', $this).prop('disabled', true); $.ajax({ type: "POST", url: "&lt;?= base_url('admin/update/add')?&gt;", data: "add="+ add + "&amp;user_id=" + user_id, success: function(){ $('form#submit').hide(); alert("Permission add added"); $('div.success').fadeIn(); } }); $(this).prop('disabled', false); } else if($('.approve'+ID, $this).is(':checked')) { $('.read', $this).prop('disabled', true); $.ajax({ type: "POST", url: "&lt;?= base_url('admin/update/approve')?&gt;", data: "approve="+ approve + "&amp;user_id=" + user_id, success: function(){ $('form#submit').hide(); alert("Permission approve added"); $('div.success').fadeIn(); } }); $(this).prop('disabled', false); } else{ $('input[type=checkbox]', $this).prop('disabled',false); $(this).prop('disabled',false); } }); }); }); </code></pre> <p></p> <p>And also I wanted to initialize the checkboxes to what they should be. The rules are.</p> <p>When a user has read permission (add &amp; approve should be disabled). When a user has add/approve (only read should should be disabled).</p> <p>On my jQuery script it already works but if it's reload triggered it doesn't..</p> <p>HTML:</p> <pre><code>&lt;table width="100%" id="list-tbl"&gt;&lt;form id="permissions2"&gt;&lt;tr id="tr2"&gt;&lt;td&gt;Sia Olsen&lt;/td&gt;&lt;td align="right"&gt;&lt;input type="hidden" name="user_id" id="user_id" value="2" /&gt;Read&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="checkbox" name="read2" id="read2" class="read2" checked /&gt;Add&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="checkbox" name="add2" id="add2" class="add2" checked /&gt;Approve&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="checkbox" name="approve2" id="approve2" class="approve2" checked /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/form&gt;&lt;form id="permissions3"&gt;&lt;tr id="tr3"&gt;&lt;td&gt;Mary Lee&lt;/td&gt;&lt;td align="right"&gt;&lt;input type="hidden" name="user_id" id="user_id" value="3" /&gt;Read&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="checkbox" name="read3" id="read3" class="read3" checked /&gt;Add&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="checkbox" name="add3" id="add3" class="add3" /&gt;Approve&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="checkbox" name="approve3" id="approve3" class="approve3" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/form&gt;&lt;/table&gt; &lt;/div&gt;&lt;/div&gt; </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.
    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