Reputation: 199
I'm designing this code and it doesn't work. Can anyone help me?
The jQuery:
$('.cuttingCheckbox').change(function() {
if (this.checked) {
$.post(
'process_class.php',
{
headmark : $($row[HEAD_MARK]).val(),
headmark_id : $($row[ID]).val()
},
function(response){
this.setAttribute("disabled", true), alert(headmark, headmark_id);
}
);
}
});
and the code,
$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 "<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' class='cuttingCheckbox' name='cuttingCheckbox'/></td>";
}
echo "</tr>";
echo "</tbody>";
echo "<table cellspacing = '0'";
}
echo "</table>";
And the process_class.php
just processing $row[HEAD_MARK]
and $row[ID]
passed to update the database. I don't know how to pass the $row[HEAD_MARK]
and $row[ID]
into the jQuery. Please help me
Upvotes: 0
Views: 77
Reputation: 109
Your problem might be in this jquery statement
{ headmark : $($row[HEAD_MARK]).val(),
headmark_id : $($row[ID]).val()
}
can you please explain which value you are trying to get from HTML dom tree using jquery.
since you have to either use # if field from which you want get value using jquery has id attribute with same name.
so try like below:
{ headmark : $('#<?php echo $row[HEAD_MARK]?>').val(),
headmark_id : $('#<?php echo $row[ID]?>').val()
}
if field is identified by id.
Edit:
change your PHP code line to look like this:
echo "<td><input type='checkbox' data-headmark=".$row['HEAD_MARK']." data-id=".$row['ID']." class='cuttingCheckbox' name='cuttingCheckbox'/></td>";
And:
change your jQuery code line to look like this:
{ headmark : $(this).data('headmark'),
headmark_id : $(this).data('id')
}
Also:
make sure that in process_class.php script update Query should have quote around head_mark if it is varchar type like below:
"UPDATE FABRICATION_QC SET CUTTING = 'Y'
WHERE HEAD_MARK = '".$_POST["headmark"]."' AND ID = ".$_POST["headmark_id"].";"
Now apply this three changes and try again.
Upvotes: 1