Hi Folks, I need help with my Project. I need to pull a value from the populated dropdown list using an ORACLE DB. When I pulled that value, I need to fill the quantity with the corresponding quantity value and show it to the user. And I also need to show the user the current progress (integer) in the input bar (number) so that when the user see the current progress they can see how many is completed and change the value.

I know it has to be done using AJAX and I just dont know how to do it. Please Please help me...

require_once 'db_connect.php';

<?php
    $paint_parse = oci_parse($conn, 'SELECT HEAD_MARK FROM FABRICATION ORDER BY REV_DATE');
    oci_define_by_name($paint_parse, 'HEAD_MARK', $head_mark);
    oci_execute($paint_parse, OCI_DEFAULT);
?>

<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">
                                        <label for="headmark" class="lbl-ui select">
                                          <select id="headmark" name="headmark" onChange="">
                                                <?php while (oci_fetch($paint_parse)){?>
                                                <option value="headmark_sel" id="headmark"> <?php echo "$head_mark"; ?></option> <?php } ?>
                                          </select>
                                        </label>     
                                    </div>   
                                </div>                        
                           </section>                                                  
                           <section>
                                <div class="row">
                                    <div class="col4 first">
                                        <label for="lnames" class="lbl-text tleft">Total Quantity:</label>
                                    </div><!-- end .col4 section -->
                                    <div class="col8 last">
                                        <label class="lbl-ui">
                                            <!-- Show Corresponding head mark quantity in this field -->
                                            <h1><?php $qty_parse ?></h1>
                                        </label>
                                    </div><!-- end .col8 section -->  
                                </div><!-- end .row section-->                            
                           </section>
                       <fieldset>
                           <legend>&nbsp  Current Progress INFO and UPDATE<span class="bubble blue">2</span> </legend>
                            <section>
                                <div class="row">
                                    <div class="col4 first">
                                        <label for="lnames" class="lbl-text tleft">CUTTING:</label>
                                    </div><!-- end .col4 section -->
                                    <div class="col8 last">
                                        <label class="lbl-ui">
                                            <input type="number" name="lnames" id="lnames" class="input" placeholder="Enter Name" />
                                            <h1><?php $qty_parse ?></h1>
                                        </label>
                                    </div><!-- end .col8 section -->  
                                </div><!-- end .row section-->                            
                           </section>
                           <section>

Hi

Can you please check the below

<option value="headmark_sel" id="headmark"> <?php echo "$head_mark"; ?></option> <?php } ?>

Replace it as

<option value="<?php echo $head_mark; ?>" id="<?php echo $head_mark; ?>"> <?php echo $head_mark; ?></option> <?php } ?>

It still doesnt work ....
I tried to replace it with your solution
I still keep getting undefined index q

i added the script like this

function showQty(str){
        if (str==""){
          document.getElementById("txtHint").innerHTML="";
          return;
          } 
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
          } else {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function(){
          if (xmlhttp.readyState==4 && xmlhttp.status==200){
            document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
            }
          }
        xmlhttp.open("GET","update_fab_progress.php?q="+str,true);
        xmlhttp.send();
        }

and the PHP,

<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">
                                        <label for="headmark" class="lbl-ui select">
                                          <select id="headmark" name="headmark" onChange="javascript:showQty(this.value)">
                                                <option value=" ">Select Head Mark</option>
                                                <?php while (oci_fetch($paint_parse)){?>
                                                <option value="<?php echo $head_mark; ?>" id="<?php echo $head_mark; ?>"> <?php echo $head_mark; ?></option> <?php } ?>
                                          </select>
                                        </label>     
                                    </div>   
                                </div>                        
                           </section>                                                  
                           <section>
                                <div class="row">
                                    <div class="col4 first">
                                        <label for="lnames" class="lbl-text tleft">Total Quantity:</label>
                                    </div><!-- end .col4 section -->
                                    <div class="col8 last">
                                        <label class="lbl-ui">
                                            <!-- Show Corresponding head mark quantity in this field -->
                                            <?php
                                            $q = intval($_GET["q"]);
                                            $result = oci_parse($conn, "SELECT QTY FROM FABRICATION WHERE HEAD_MARK = '".$q."'");

                                            oci_execute($result);

                                                $row = oci_fetch($result);
                                            ?>
                                            <h1><?php echo $row ?></h1>
                                        </label>
                                    </div><!-- end .col8 section -->  
                                </div><!-- end .row section-->                            
                           </section>

Hi

Use the below line from 26. Let me check. and also please echo $q, the value is getting.

<?php
                                            $q = intval($_GET["q"]);
                                            $result = oci_parse($conn, "SELECT QTY FROM FABRICATION WHERE HEAD_MARK = '".$q."'");

    oci_define_by_name($result, 'QTY', $qty);
                                            oci_execute($result);

                                                oci_fetch($result);
                                            ?>
                                            <h1><?php echo $qty ?></h1>
                                            <?php oci_free_statement($result); ?>

I have same issue , in oracle with php. Still not solved yet :(

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.