Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring values in a database via AJAX not working
    primarykey
    data
    text
    <p>I have this function which uses ajax, but this function doesn't work. I tried a lot, but I'm not able to figure out where the problem is. I am trying to create an alert, when the user inserts a duplicate entry into the database using a check-box selection.</p> <pre><code>&lt;script&gt; function func(e,eid,emprid) { if(document.getElementById(e).checked){ var dataString = 'eid=' + eid + '&amp;emprid='+emprid; $.ajax({ type:"POST", url: "mylistcheck.php", data: dataString, success: function(result){ if(result!='0') { modal.open({content: "&lt;span style=\"color:red\" &gt;&lt;h2&gt;You have already selected candidate &lt;/h2&gt;&lt;/span&gt;"}); document.getElementById(e).checked=false; } } }); } } &lt;/script&gt; </code></pre> <p><code>mylistcheck.php</code> looks like this:</p> <pre><code>&lt;?php require_once("includes/session.php"); ?&gt; &lt;?php require_once("includes/connection.php"); ?&gt; &lt;?php require_once("includes/functions.php"); ?&gt; &lt;?php $eid=$_POST['eid']; $emprid=$_POST['emprid']; $sqlchecklist="SELECT * FROM selected_candidate WHERE eid='{$eid}' AND rid='{$emprid}' "; $checklistres=mysql_query($sqlchecklist); $list_check=mysql_num_rows($checklistres); echo "numrows listcheck".$list_check; if($list_check&gt;0) { echo "1"; } else { echo "0"; } ?&gt; </code></pre> <p>The check-box code is like this:</p> <pre><code>echo "&lt;td&gt;&lt;input id=\"select_candi{$i}\" onclick=\"javascript:func(this.id,{$data_set['eid']},{$emprid})\" type=\"checkbox\" name=\"check_candi[]\" value=\"{$data_set['eid']},{$emprid}\"/&gt;&lt;/td&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