<?php
  $valor1 = $_GET['v1'];
  
  //conexion a la base de datos
  include("conexionOdo.php"); 
  //consulta cups
  $query="SELECT * from SIO_PROC_POS WHERE descripcion LIKE '%$valor1%' order by descripcion";
  $result = mysql_query($query) or die('Consulta de Cups  Medicina fallida: ' . mysql_error());
  //$line = mysql_fetch_array($result, MYSQL_ASSOC);
    
  $comboProPos="";
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
  {
   if ($i==0)
    {
     $comboProPos .=" <option value=''>".''."</option>";
    }
   $comboProPos .=" <option value='".$line['cups']."'>".$line['descripcion']."</option>"; 
   
   $i++;
  }
  // Liberar resultados
  mysql_free_result($result); 
    
?>

<html>
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>Lista Procedimientos</title>
   <style type="text/css" media="all">@import "./estilos.css";</style>
   
   <script type="text/javascript">
     function cerrar() 
     {
       var posicion = window.document.getElementById('cups').options.selectedIndex; 
       if (posicion > 0)
       {
         var data1 =  window.document.getElementById('cups').options[posicion].value;
         var data2 =  window.document.getElementById('cups').options[posicion].text;
         var data3 = "Cups"; 
         window.opener.document.getElementById('coPro_s').innerHTML = data1;  
         window.opener.document.getElementById('noPro_s').innerHTML = data2;  
         window.opener.document.getElementById('tiPro_s').innerHTML = data3;  
                   
       }
       this.window.close();
     }
   </script>
 </head>
    
 <body>
    <table align='center' width="650" height="25">
      <tr>
        <td align="center" class="titulosTabla2" >HISTORIA CLINICA MEDICA </td>
      </tr>
      
      <tr class="titulosTabla">
        <td><label>PROCEDIMIENTOS</label></td>
      </tr>    
    </table>
    
    <!-- <input type="text" id="val1" value="<?php echo $res;?>" disabled="disabled"/> -->
        
    <table align='center' border="1" width="650">
     <tr>
       <td align="left" class="camposTabla">
         <select name="cups" id="cups" style="width:500">
           <?php echo $comboProPos; ?>
         </select>
       </td>
       <td align='center'>
         <button onclick="cerrar();">Seleccionar</button> 
       </td>
     </tr>
     <tr>
       <td class="subtutulosTabla" align="center" colspan ="2">
         <label>Seleccione el Procedimiento de la lista y Toque 'Seleccionar' </label>
       </td> 
     </tr> 
    </table>     
 </body>
</html>