
                   
                       <div class="table-responsive" style="overflow-x:auto;">
                                            <table id="report-table" class="table table-bordered table-striped mb-0">
                                                <thead>
                                                   
                                                    <tr>
                                                       
                                                      <th width="50"> Short Key </th>     
                                                        <th width="250"> Name </th>
                                                       <!--  <th width="90">Dose</th> -->
                                                        <th width="90">Freq.</th>
                                                       <!--  <th width="90">Duration</th> -->
                                                        <th style="width: 10px;"></th>
                                                    </tr>
                                                </thead>
                                                <tbody id="prevtreatments">
                                                    <?php 
                                                    $sql66 = "SELECT * FROM tbl_consultant_treatments WHERE VisitDate='$VisitDate' AND MrdNo='$MrdNo'";
                                                    $row66 = getList($sql66);
                                                    foreach($row66 as $result66){
                                                    ?>
                                                    <tr id="svtr<?php echo $result66['id'];?>">
                                                       <!--<td>
                                                            <input class="form-control" type="text" list="Treat_Type1" name="TreatType1[]"  id="TreatType1" value="<?php echo $result66['TreatType1'];?>">
                                                                <datalist id="Treat_Type1">
                                                                    <?php $sql = "SELECT DISTINCT(TreatType1) As TreatType1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatType1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                         </td>-->
                                                          <td><input class="form-control" type="text" name="ShortKey1[]" list="Short_Key1" id="ShortKeysv<?php echo $result66['id'];?>" oninput="checkShortKey2(<?php echo $result66['id'];?>)">
                                                           
                                                          </td>
                                                        <td>
                                                            <input class="form-control" list="Treat_Name1" type="text" name="TreatName1[]"  id="TreatNamesv<?php echo $result66['id'];?>" value="<?php echo $result66['TreatName1'];?>" oniput="findfollow()">
                                                             <datalist id="Treat_Name1">
                                                                <?php $sql = "SELECT DISTINCT(TreatName1) As TreatName1 FROM tbl_consultant_treatments UNION ALL SELECT DISTINCT(Name) As TreatName1 FROM tbl_drugs";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatName1']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                               
                                                        </td>
                                                        <!-- <td>
                                                            <input class="form-control" type="text" list="Treat_Dose1" name="TreatDose1[]"  id="TreatDose1" value="<?php echo $result66['TreatDose1'];?>">
                                                                <datalist id="Treat_Dose1">
                                                                <?php $sql = "SELECT DISTINCT(TreatDose1) As TreatDose1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatDose1']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                        </td> -->
                                                        <td>
                                                            <input class="form-control" type="text" list="Treat_Freq1" name="TreatFreq1[]"  id="TreatFreqsv<?php echo $result66['id'];?>" value="<?php echo $result66['TreatFreq1'];?>">
                                                                <datalist id="Treat_Freq1">
                                                               <?php $sql = "SELECT FreqName As TreatFreq1 FROM tbl_freq";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatFreq1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                        </td>
                                                        <!-- <td>
                                                            <input class="form-control" type="text" list="Treat_Dur1" name="TreatDur1[]"  id="TreatDur1" value="<?php echo $result66['TreatDur1'];?>">
                                                                <datalist id="Treat_Dur1">
                                                                <?php $sql = "SELECT DISTINCT(TreatDur1) As TreatDur1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatDur1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                        </td> -->
                                                       
                                                       <!--  <td></td> -->
                                                     <td align="center" valign="top"><button class="btn btn-danger btn_remove" type="button" id="<?php echo $i;?>" onclick="removeTreatment2('TreatNamesv<?php echo $result66['id'];?>','TreatFreqsv<?php echo $result66['id'];?>','<?php echo $result66['id'];?>')"><i class="feather icon-x"></i></button>
                                                           </td> 
                                                    </tr>
                                                <?php } ?>
                                                </tbody>
                                                 <tbody id="dynamic_field">
                                                   <?php for($i=1;$i<=10;$i++){?>
                                                   <tr>
                                                       <!--  <td align="center" valign="top"><input class="form-check-input" type="checkbox" value="1" name="TreatChk1">
                                                           </td> -->
                                                        <!--<td>
                                                            <input class="form-control" type="text" list="Treat_Type1" name="TreatType1[]"  id="TreatType1">
                                                                <datalist id="Treat_Type1">
                                                                <?php $sql = "SELECT DISTINCT(TreatType1) As TreatType1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatType1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                         </td>-->
                                                         <td><input class="form-control" type="text" name="ShortKey1[]" list="Short_Key1" id="ShortKey<?php echo $i;?>" oninput="checkShortKey(<?php echo $i;?>)">
                                                            
                                                         </td>
                                                        <td>
                                                            <input class="form-control" list="Treat_Name1" type="text" name="TreatName1[]"  id="TreatName<?php echo $i;?>">
                                                             <datalist id="Treat_Name1">
                                                                <?php $sql = "SELECT DISTINCT(TreatName1) As TreatName1 FROM tbl_consultant_treatments UNION ALL SELECT DISTINCT(Name) As TreatName1 FROM tbl_drugs";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatName1']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                               
                                                        </td>
                                                        <!-- <td>
                                                            <input class="form-control" type="text" list="Treat_Dose1" name="TreatDose1[]"  id="TreatDose1">
                                                                <datalist id="Treat_Dose1">
                                                                <?php $sql = "SELECT DISTINCT(TreatDose1) As TreatDose1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatDose1']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                        </td> -->
                                                        <td>
                                                            <input class="form-control" type="text" list="Treat_Freq1" name="TreatFreq1[]"  id="TreatFreq<?php echo $i;?>">
                                                                <datalist id="Treat_Freq1">
                                                               <?php $sql = "SELECT FreqName As TreatFreq1 FROM tbl_freq";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatFreq1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                        </td>
                                                       <!--  <td>
                                                            <input class="form-control" type="text" list="Treat_Dur1" name="TreatDur1[]"  id="TreatDur1">
                                                                <datalist id="Treat_Dur1">
                                                                <?php $sql = "SELECT DISTINCT(TreatDur1) As TreatDur1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatDur1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                        </td> -->
                                                       

                                                         <td align="center" valign="top"> <button class="btn btn-danger btn_remove" type="button" id="<?php echo $i;?>" onclick="removeTreatment('TreatName<?php echo $i;?>','TreatFreq<?php echo $i;?>')"><i class="feather icon-x"></i></button></td>

                                                    </tr>
                                                    <?php } ?>
                                                    <tr>
                                                       <!--  <td align="center" valign="top"><input class="form-check-input" type="checkbox" value="1" name="TreatChk1">
                                                           </td> -->
                                                        <!--<td>
                                                            <input class="form-control" type="text" list="Treat_Type1" name="TreatType1[]"  id="TreatType1">
                                                                <datalist id="Treat_Type1">
                                                                    <?php $sql = "SELECT DISTINCT(TreatType1) As TreatType1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatType1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                         </td>-->
                                                           <td><input class="form-control" type="text" name="ShortKey1[]" list="Short_Key1" id="ShortKeynv1" oninput="checkShortKey3(1)">
                                                             <datalist id="Short_Key1">
                                                                <?php $sql = "SELECT ShortKey FROM tbl_drugs";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['ShortKey']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                           </td>
                                                        <td>
                                                           <input class="form-control" list="Treat_Name1" type="text" name="TreatName1[]"  id="TreatNamenv1">
                                                             <datalist id="Treat_Name1">
                                                                <?php $sql = "SELECT DISTINCT(TreatName1) As TreatName1 FROM tbl_consultant_treatments UNION ALL SELECT DISTINCT(Name) As TreatName1 FROM tbl_drugs";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatName1']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                               
                                                        </td>
                                                        <!-- <td>
                                                            <input class="form-control" type="text" list="Treat_Dose1" name="TreatDose1[]"  id="TreatDose1">
                                                                <datalist id="Treat_Dose1">
                                                                <?php $sql = "SELECT DISTINCT(TreatDose1) As TreatDose1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatDose1']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                        </td> -->
                                                        <td>
                                                            <input class="form-control" type="text" list="Treat_Freq1" name="TreatFreq1[]"  id="TreatFreq1">
                                                                <datalist id="Treat_Freq1">
                                                               <?php $sql = "SELECT FreqName As TreatFreq1 FROM tbl_freq";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatFreq1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                        </td>
                                                       <!--  <td>
                                                            <input class="form-control" type="text" list="Treat_Dur1" name="TreatDur1[]"  id="TreatDur1">
                                                                <datalist id="Treat_Dur1">
                                                                <?php $sql = "SELECT DISTINCT(TreatDur1) As TreatDur1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatDur1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                        </td> -->
                                                       

                                                         <td align="center" valign="top"> <button class="btn btn-primary" type="button" id="add_more"><i class="feather icon-plus"></i></button>
                                                           </td>

                                                    </tr>
                                                      
                                                </tbody>
                                                
                                            </table>
</div>  
               