Note that there are some explanatory texts on larger screens.

plurals
  1. POform validation using javascript in codeigniter
    primarykey
    data
    text
    <p>hi i have a jquery table populate from datebase:</p> <pre><code>&lt;?php $attributes = array('name' =&gt; 'users'); echo form_open('users/action',$attributes);?&gt; &lt;table class="data display datatable" id="example"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Username&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Nickname&lt;/th&gt; &lt;th&gt;Birthday&lt;/th&gt; &lt;th&gt;Sex&lt;/th&gt; &lt;th&gt;Address&lt;/th&gt; &lt;th&gt;&lt;input type="checkbox" id="select all"&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php foreach($query-&gt;result_array() as $row): ?&gt; &lt;tr class="even gradeC"&gt; &lt;td&gt;&lt;?php echo anchor('users/details/'.$row['usrID'],$row['usrName']);?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['usrpFirstName'].' '.$row['usrpLastName'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['usrpNick'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['usrpBday'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['usrpSex'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['usrpAddress'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="checkbox" name="checkID[]" id="checkID" value="&lt;?php echo $row['usrID'];?&gt;" /&gt; &lt;label for="checkID"&gt;&lt;/label&gt;&lt;/td&gt; &lt;/tr&gt; &lt;? endforeach; ?&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;input type="submit" name="Delete" id="Delete" value="Delete" class="btn btn-orange" /&gt; &lt;input type="submit" name="Edit" id="Edit" value="Edit" class="btn btn-orange" onclick="return validateForm()" /&gt; &lt;input type="submit" name="AddUser" id="Add User" value="Add User" class="btn btn-orange" /&gt; &lt;/form&gt; </code></pre> <p>as you can see below,, i use <code>checkID[]</code> so that i can get every id of each user. i did make a <code>onlick</code> on edit button so that it will check if the id is empty or not. heres my js function</p> <pre><code>&lt;head&gt; &lt;script type="text/javascript"&gt; function validateForm() { var x=document.forms["users"]["checkID[]"].value if (x==null || x=="") { alert("Please select user to edit."); return false; } } &lt;/script&gt; &lt;/head&gt; </code></pre> <p>the problem now is that it will still alert even i check one user in the table.. </p> <p>even i use this:</p> <pre><code>&lt;?php $attributes = array('name' =&gt; 'users' , 'onsubmit' =&gt;"return validateForm()"); echo form_open('users/action',$attributes);?&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.
    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