Hi folks, first of all I am new here and i wanna say hello guys. I am working on a project that is stuck right now. So the idea is I have the checkboxes generated from the oci_fetch_array() into a table and when user check the checkbox, it automatically updates the database with corresponding data and disable the checkbox. My code is as follows, This is the jQuery $('.cuttingCheckbox').change(function() { if (this.checked) { $.post('process_class.php',{ headmark : $(this).data('headmark'), headmark_id : $(this).data('id') }, function(response){ this.setAttribute("disabled", true), alert(headmark,headmark_id); }); } }); Code (JavaScript): and on the same page, I have the html markups, <?php // IF SHOW KEY HAS BEEN PRESSED if($_POST['action'] == 'show') { $sql = "SELECT * FROM FABRICATION WHERE FABRICATION.HEAD_MARK = '{$_POST["hm"]}'"; $query = oci_parse($conn, $sql); $query_exec = oci_execute($query); while($row = oci_fetch_assoc($query)){ echo "<input type='hidden' id='headmarkid' value='".$row['HEAD_MARK']."' />"; echo "<input type='hidden' id='rowid' value='".$row['ID']."' />"; echo "<table border='1'>"; echo '<table cellspacing = "0"'; echo '<thead>'; echo '<tr><th>Head Mark/ID</th> <th>Cutting</th> </tr></thead>'; echo "<tbody>"; echo "<tr><td><b>$row[HEAD_MARK]/$row[ID]</b></td>"; if ($row['CUTTING'] == 'Y'){ //echo "<td><input type='checkbox' id='cuttingCheckbox' name='cuttingCheckbox' checked='checked' disabled='disabled'/></td>"; echo "<td><img src='../images/fabDone.png' width='30' height='30'></td>"; } else { echo "<td><input type='checkbox' data-headmark=".$row['HEAD_MARK']." data-id=".$row['ID']." class='cuttingCheckbox' name='cuttingCheckbox'/></td>"; } echo "</tr>"; echo "</tbody>"; echo "<table cellspacing = '0'"; } echo "</table>"; }//===> END OF 'SHOW' ?> PHP: and on the process_class.php I have this <?php $cuttingUpdateParse = oci_parse($conn,"UPDATE FABRICATION_QC SET CUTTING = 'Y' WHERE HEAD_MARK = ".$_POST["headmark"]." AND ID = ".$_POST["headmark_id"].";"); $cuttingUpdateRes = oci_execute($cuttingUpdateParse); if ($cuttingUpdateRes){ oci_commit($conn); echo "<script>alert('CUTTING UPDATED');</script>"; } else { echo "<script>alert('CUTTING NOT UPDATED');</script>"; } ?> PHP: The problem is when i click cutting, nothing happened. Please help me guys, any kind of help will be greatly appreciated cheers,
Your jQuery function is wrong - you need to assign $(this) to a variable inside the function to be able to reuse it inside $.post() - something like this: $('.cuttingCheckbox').change(function() { if (this.checked) { var $this = $(this); $.post('process_class.php',{ headmark : $this.data('headmark'), headmark_id : $this.data('id') }, function(response){ $this.prop("disabled", true); alert(headmark,headmark_id); }); } }); Code (markup): That should at least trigger the function and return no errors. Besides, you would have seen the errors if you used Firebug's Console, or similar inspectors.
i did as you suggested but it still doesnt work. Firebug says this.prop / this.setAttribute is not a function
Then you didn't add the $this-variable. Just use the function as I copied above. And make sure you're using it within the document ready function.