Hi Folks,

I need help with my code. Basically I am building an inventory progress web so that it pulls the value from the dropbox, and with onChange, getting the corresponding value from the DB, Update the value and reinsert the new value to the DB using submit button. One thing that doesnt work is only the submit button and ive been trying so hard to resolve this kind of issue. PLease help me, any kind of help would be greatly appreciated.

// ASSUME THE CONNECTION IS DONE with $conn

if (isset($_POST["ajax"]) && $_POST["ajax"] == 1){
       $sql = "SELECT QTY FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'";
       $cutting_sql = "SELECT CUTTING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'";

       $stid = oci_parse($conn, $sql);
       $stid_cutting = oci_parse($conn, $cutting_sql);

        // The defines MUST be done before executing
        oci_define_by_name($stid, 'QTY', $qty);
        oci_execute($stid);

        oci_define_by_name($stid_cutting, 'CUTTING', $cutting);
        oci_execute($stid_cutting);  

        // Each fetch populates the previously defined variables with the next row's data
        oci_fetch($stid);
        oci_fetch($stid_cutting);


        //echo quantity to the screen
        echo "<b><font size='10'>".$qty."</font></b></br>";
        if ($cutting == $qty){
            echo "<p><b><font color='#FF8566' size='5'>CUTTING COMPLETED</font></b></p>";
        } else {
            $maxcutting = $qty - $cutting;
            echo "<input id='cutting' name='cutting' type='number' min = '0' max = '$maxcutting' placeholder='CUTTING DONE: $cutting' class='input'/>";
        }

        // THIS IS WHERE THE PROBLEM STARTS
        echo '<section></br></br></br>'; 
        echo '       <input type="submit" name="submit" value="SUBMIT PROGRESS" class="button red" />';
        if (isset($_GET['submit'])){

            oci_bind_by_name($statement, $cuttingz, $_POST["cutting"]);
            echo $cuttingz;
            echo '<script type="text/javascript">alert("hello button pressed");</script>'; 
        }
        echo '       <input type="reset"  value="RESET FIELDS"    class="button" /></br>';
        echo '       <input type="button" value="GO TO PAINTING"  name="paint" id="paint" class="button green" /></section>';  

        die;
} //AJAX--Closing--Brace
?>

<!DOCTYPE html>
<html lang="en">
<head>
       <script type="text/javascript">
           function OnSelectionChange (select) {
            var selectedOption = select.options[select.selectedIndex];
            //some ajax checkpoint
            //alert ("The selected option is " + selectedOption.value);          
                        jQuery.ajax({
                                url: location.href,
                                data: {'hm':selectedOption.value, 'ajax':1},
                                type: "POST",
                                success: function( data ) {
                                        jQuery("#lbl_qty").html(data);//PRINT QTY TO THE SCREEN
                                }                           
                        });
                        //some ajax checkpoint
                        //alert('after ajax');
            }

       </script>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
</head>
</body>

                                        <!-- POPULATED DROPDOWN LIST FROM THE DB -->
                                        <label for="headmark" class="lbl-ui select">
                                            <?php         
                                             $sql_hm_comp = 'SELECT HEAD_MARK FROM FABRICATION';

                                            $result = oci_parse($conn, $sql_hm_comp);
                                            oci_execute($result);

                                            echo '<SELECT name="headmark" id="headmark" onchange="OnSelectionChange(this)">'.'<br>';
                                            echo '<OPTION VALUE=" ">'."".'</OPTION>';

                                            while($row = oci_fetch_array($result,OCI_ASSOC)){
                                                 $HM = $row ['HEAD_MARK'];
                                                 echo "<OPTION VALUE='$HM'>$HM</OPTION>";
                                            }
                                            echo '</SELECT>';
                                        ?>
                                        </label>     
                                    </div>   
                                </div>                        
                           </section><!-- END OF DROPDOWN LIST -->                                              
                          <section>
                                <div class="row">
                                    <div class="col4 first">
                                        <label for="lnames" class="lbl-text tleft">Total Quantity:</label>
                                    </div>
                                    <div class="col8 last">
                                    <!-- VALUE PASSED FROM AJAX PROCESSING -->
                                    <label id='lbl_qty' class='lbl-ui'><font size='3'></font></label>               
                                    </div>   
                                </div>                        
                           </section> 
            </form>
</body>
</html>

Is that HTML a complete copy of the code you are using?
You have a body end tag instead of a body opening tag, and I cannot see the form opening tag, only the form end tag.
If you change the button from a 'submit' to a 'button', just for testing, does it trigger your event handler?
The 'submit' works on a form, causing a submit to the server, so not having the form opening tag will be an issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.