Jump to content

Please help me.. My Submit button doesnt work :)


chrishutagalung

Recommended Posts

Hello all,

 

I am designing a program that consists of 1 dropdown list that pulled the value from the ORACLE DB and update the value as we change the Dropdown. I can get everything works except the submit button when we want to update the value. Please help me, I know this is a very simple problem but somehow it doesnt work. Your help with greatly appreciated.

 

Thanks,


// ASSUME CONNECTION IS DONE

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>
                </div>
                <div class="form-buttons">
                              
                </div>
            </form>
            </div>
    </div> 
    <div></div>
    <div></div>
</body>
</html>
Link to comment
Share on other sites

the only apparent problem is that your submit button doesn't have a name= ' ... ' attribute, so there's nothing to reference when the form is submitted.

 

a comment about the database code you are showing in this thread. you would NEVER run seven queries, with seven sets of repetitive code that only varies by the field it operates on, to fetch the values from ONE row in a database table. you would run one query to retrieve the one row, fetch the data that query returned, and either use the fetched data directly as the corresponding array elements, or if appropriate, assign the array elements to individual variables.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.