PROBLEM Form onchange erases fields already written

0

good afternoon. I have a problem and I would like to know if someone could give me a cable.

I have a form: in certain fields, I use the onchange="this.form.submit ()" property in the select, so that I send the value through $ _POST, save it in a variable, and use it in another field. ..

The problem is that, when filling out text fields, and then filling in one of these select, all the fields

<form id="pedidost" method="POST">

  <label for="familiasod">Familia de lentes:</label>

   <select name="familiasod" onchange="this.form.submit()">
     <option value="1od" disabled>-- Seleccione tipo de lentes --</option>
     <option value="stockod" selected>Monofocal Stock</option>
     <option value="labod">Monofocal Fabricacion</option>
     <option value="progresivosod">Progresivos</option>
     <option value="bifocalesod">Bifocales</option>
   </select>

  <input name="fecha" id="fecha" value="<?php echo date("d/m/Y"); ?>" size="7">
  <input type="text" name="nombre" placeholder="Referencia">

  <select name="remoto" >
    <option value="" selected disabled>- Sin Cortar / Biselado -</option>
    <option value="uncut">Sin Cortar Lente</option>
    <option value="edged">Biselado Remoto</option>
  </select>

  <div class="row">
  <div class="column">
   <h4>Lente Ojo Derecho</h4>

     <select name="stock_od" onchange="this.form.submit()">
      <option value="0" disabled selected>Seleccione diseño </option>
           <?php
                  /* creamos la consulta */
                  $result=mysqli_query($link, "SELECT * FROM disenyos where id_familia = 1;");

                  /* utilizamos un ciclo repetitivo para obtener los datos de la tabla */            

                  while ($valores = mysqli_fetch_array($result)) {

                      /* preguntamos si es el seleccionado por el usuario */
                      if (isset($_POST['stock_od'])){

                      if($valores['id_disenyo']==$_POST['stock_od']){
                      ?>

                      <!-- Llenamos el select con lo seleccionado por el usuario -->
                      <!-- Agrego el id del diseño como valor del campo -->
                      <option value="<?php echo $valores['id_disenyo'] ?>"selected> <?php echo $valores['nombre']; ?> </option>

                     <?php 
                       }

                      else {
                           ?>
                     <!-- Llenamos el select con los datos de la tabla -->
                     <!-- Agrego el id del diseño como valor del campo -->
                     <option value="<?php echo $valores['id_disenyo'] ?>"> <?php echo $valores['nombre']; ?> </option>   
                     <?php                    
                          } /* cierre del else $valores*/ 
                       } /* cierre del if del isset */

                      else {
                     ?>
                      <!-- Llenamos el select con los datos de la tabla -->
                      <!-- Agrego el id del diseño como valor del campo -->
                      <option value="<?php echo $valores['id_disenyo'] ?>"> <?php echo $valores['nombre']; ?> </option>   
                      <?php                    
                                  } /* cierre del else del isset*/
                      } /* cierre del while */
                      ?>
          </select>

I do not add more code because I do not see it necessary, it is supposed that when you click on any value of the select with "name=" stock_od ", if there was something written in" Reference "it is deleted.

I would need someone to help me please.

Greetings.

    
asked by Javier Avila Fernandez 10.01.2018 в 18:08
source

0 answers