Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2014
    Posts
    44

    Unanswered: Submit button doesnt work.. Please help me

    Please help me with my code... my submit button doesnt work. Its a combination of PHP and javascript and I am making the dropdown work with database and when i pulled the value from the database, make the modification and update the database with the new value.

    Thanks,

    PHP Code:
    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"]}'";
           $assembly_sql = "SELECT ASSEMBLY FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'";
           $welding_sql = "SELECT WELDING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'";
           $drilling_sql = "SELECT DRILLING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'";
           $finishing_sql = "SELECT FINISHING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'";
           
           $stid = oci_parse($conn, $sql);
           $stid_cutting = oci_parse($conn, $cutting_sql);
           $stid_assembly = oci_parse($conn, $assembly_sql);
           $stid_welding = oci_parse($conn, $welding_sql);
           $stid_drilling = oci_parse($conn, $drilling_sql);
           $stid_finishing = oci_parse($conn, $finishing_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);
            
            oci_define_by_name($stid_assembly, 'ASSEMBLY', $assembly);
            oci_execute($stid_assembly);
            
            oci_define_by_name($stid_welding, 'WELDING', $welding);
            oci_execute($stid_welding);
            
            oci_define_by_name($stid_drilling, 'DRILLING', $drilling);
            oci_execute($stid_drilling);
            
            oci_define_by_name($stid_finishing, 'FINISHING', $finishing);
            oci_execute($stid_finishing);

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

            //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 PROGRESS TODAY' class='input'/>";
            }
           
            if ($assembly == $qty){
                echo "<p><b><font color='#FF8566' size='5'>ASSEMBLY COMPLETED</font></b></p>";
            } else {
                $maxassembly = $qty - $assembly;
                echo "<input id='assembly' name='assembly' type='number' min = '0' max = '$maxassembly' placeholder='ASSEMBLY PROGRESS TODAY' class='input'/>";
            }
            
            if ($welding == $qty){
                echo "<p><b><font color='#FF8566' size='5'>WELDING COMPLETED</font></b></p>";
            } else {
                $maxwelding = $qty - $welding;
                echo "<input id='welding' name='welding' type='number' min = '0' max = '$maxwelding' placeholder='WELDING PROGRESS TODAY' class='input'/>";
            }
            
            if ($drilling == $qty){
                echo "<p><b><font color='#FF8566' size='5'>DRILLING COMPLETED</font></b></p>";
            } else {
                $maxdrilling = $qty - $drilling;
                echo "<input id='drilling' name='drilling' type='number' min = '0' max = '$maxdrilling' placeholder='DRILLING PROGRESS TODAY' class='input'/>";
            }
            
            if ($finishing == $qty){
                echo "<p><b><font color='#FF8566' size='5'>FINISHING COMPLETED</font></b></p>";
            } else {
                $maxfinishing = $qty - $finishing;
                echo "<input id='finishing' name='finishing' type='number' min = '0' max = '$maxfinishing' placeholder='FINISHING PROGRESS TODAY' class='input'/>";
            }
            
            echo '<section></br></br></br>'; 
            echo '       <input type="submit" value="SUBMIT PROGRESS" class="button red" />';
            echo '       <input type="reset" value="RESET FIELDS" class="button" /></br>';
            echo '       <input type="button" value="GO TO PAINTING" name="paint" class="button green" /></section>';      
            
            if (isset($_POST['paint'])){
               echo 'GO TO THE NEXT PAGE';
            }
            
            if (isset($_POST['submit'])){
               echo 'DO SUBMISSION TO THE DATABASE HERE';
            }
            die;}     
    ?>

    <!-- HTML CODE -->
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        
        <title> Update Fabrication Progress</title>
        
        <link type="text/css" rel="stylesheet"   href="../css/goldenform/golden-forms.css"/>
        <link type="text/css" rel="stylesheet"   href="../css/goldenform/font-awesome.min.css"/>
       
           <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 class="bg-wooden">
        <div class="gforms">
            <div class="golden-forms wrapper">
                <form>
                    <div class="form-title">
                        <h2>FABRICATION UPDATE</h2>                   
                    </div><!-- end .form-title section -->
                    <div class="form-enclose">
                        <div class="form-section">
                           <fieldset>
                                  <legend>&nbsp Select HEADMARK and the details will be shown <span class="bubble blue">1</span></legend>
                               <section>
                                    <div class="row">
                                        <div class="col4 first">
                                            <label for="headmark" class="lbl-text tleft">HEADMARK :</label>
                                        </div><!-- end .col4 section -->
                                        <div class="col8 last">
                                          
                                            <!-- 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> 
                       </div><!-- end .form-section section -->
                    </div><!-- end .form-enclose section -->
                    <div class="form-buttons">
                                  
                    </div><!-- end .form-buttons section -->
                </form>
                </div><!-- end .golden-forms section --> 
        </div><!-- end .gforms section -->   
        <div></div><!-- end section -->
        <div></div><!-- end section -->
    </body>
    </html>

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    there is no name property on your buttons
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Tip: get everything working without javascript first.


    Only once you have a fully functioning setup you can begin to muddy the waters with another language. Always consider that your users might not have JS enabled and so having a solution reliant on JS to function is not going to be a good one.
    George
    Home | Blog

  4. #4
    Join Date
    May 2014
    Posts
    24
    Quote Originally Posted by gvee View Post
    Tip: get everything working without javascript first.


    Only once you have a fully functioning setup you can begin to muddy the waters with another language. Always consider that your users might not have JS enabled and so having a solution reliant on JS to function is not going to be a good one.
    This is also my advice because at some point javascript screws up all the code.

  5. #5
    Join Date
    Oct 2016
    Posts
    1
    Quote Originally Posted by chrishutagalung View Post
    Please help me with my code... my submit button doesnt work. Its a combination of PHP and javascript and I am making the dropdown work with database and when i pulled the value from the database, make the modification and update the database with the new value.

    Thanks,
    The problem is with JavaScript. If you don't know, don't play around in deep.

Tags for this Thread

Posting Permissions

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