i am unable to call javascript function when checked the checkbox. i used onclick, onchange, onsubmit all method . but it is unable to run, kindly help to solve the problem. i show the checkbox in table, when i click the check box it call the javascript method and after running the php query change the label text.
<td>
<?php
if($rows[9]=="0")
{
?>
<label>
<input type="checkbox" name="confirmchecked" value="" id="confirmcheck<?php echo $rows[0] ?>" onclick="ConfirmStatus('<?php echo $rows[0] ?>');">
<span id="confirm<?php echo $rows[0]; ?>">Check to confirm </span>
</label>
<?php
}else
if($rows[9]=="1")
{
?>
<label>
<span id="confirm<?php echo $rows[0]; ?>">Valid Order </span>
</label>
<?php
}
?>
</td>
here is the javascript code , which is declare in the head tag of html
<script type="text/javascript">
function ConfirmStatus(id)
{
alert(id);
if (document.getElementById('confirmcheck'+id ).checked)
{
document.getElementById('confirmcheck'+id).style.display='none';
document.getElementById('confirm'+id).innerHTML="Valid Order";
<?php
$sql="UPDATE order_details SET isViewed=1 WHERE orderID="?>id<?php";" or die("query");
$result = mysqli_query(include("connectionDataDb.php"),$sql);
if($result)
?>
alert('Order is verified sucessfully');
}
}
function CompleteStatus(id , status)
{
if (document.getElementById('completecheck'+id ).checked)
{
alert(id+status);
}
}
</script>
Aucun commentaire:
Enregistrer un commentaire