chris.immanuel 0 Newbie Poster

Hi I have a question with my code. I implemented drop down list populated from my oracle DB.

So my question is,

I need to populate the rest of the data into my <input type="number" min="currCutting" max="currQty" /> tag that pulled from the database according to the Head_mark selected from the DDL.

Please help since I am a beginner in AJAX. Thanks,

?>

<!DOCTYPE html>
<html>
<head>
<title>Insert and Show Records using jQuery Ajax and PHP</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>

    function OnSelectionChange(str){

        // I need help to implement this method and pass them to the <input> tags below
        }

    // ===================================== //
    // ===================================== //
       $(function(){
        // AJAX CALL TO INSERT THE RECORD TO THE DATABASE
        $('#insert').click(function(){
            var jcutting = $('#fcutting').val();
            var jassembly = $('#fassembly').val();
                        var jwelding = $('#fwelding').val();
                        var jdrilling = $('#fdrilling').val();
                        var jfinishing = $('#ffinishing').val();

            //syntax - $.post('filename', {data}, function(response){});
            $.post('../update_bar/data.php',
                                    {action: "insert", "hm":$('#headmark').val(),
                                     cutting:jcutting, assembly:jassembly, welding:jwelding, 
                                     drilling:jdrilling, finishing:jfinishing},
                              function(res){
                                    $('#result').html(res);
            });     
        });

        //show records
        $('#show').click(function(){
            $.post('data.php',
                                {action: "show", "hm":$('#headmark').val()},
                                          function(res){
                $('#result').html(res);
            });     
        });
    });
</script>
</head>
<body>

    <?php         
         $result = oci_parse($conn, 'SELECT HEAD_MARK FROM FABRICATION');
         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><br />';
     ?>

<!-- MAX PLACEHOLDER SHOULD BE GATHERED FROM THE QUANTITY FROM THE CORRESPONDING HEAD_MARK-->
Cutting:</label> <input type="number" min="currCutting" max="currQty" id="fcutting" /><br />
Assembly:</label> <input type="number" min="currAssembly" max="currQty" id="fassembly" /><br />
Welding: <input type="number" min="currWelding" max="currQty" id="fwelding" /><br />
Drilling: <input type="number" min="currDrilling" max="currQty" id="fdrilling" /><br />
Finishing: <input type="number" min="currFinishing" max="currQty" id="ffinishing" /><br />

<button id="insert">Insert</button>

<h2>Show Records</h2>
<button id="show">Show</button>
<p>Result:</p>

<div id="result"></div>
</body>
</html>
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.