Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    1
    Member #
    38986

    jQuery to update database from checkbox doesnt work, Please help..

    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.

    Here is the code, for the jQuery

    Code:
    $('.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);
                   });
                   } 
               });
    And on the same page the PHP will be,
    PHP Code:
    // 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' 
    this is the process_class.php to update the database based on the passing values
    PHP Code:
    $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>";

    Any kind of help will be greatly appreciated,

    thanks guys,

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Tags for this Thread

All times are GMT -6. The time now is 08:47 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com