选择未选择的输入默认选择值

时间:2017-06-11 04:08:10

标签: html twitter-bootstrap

我在模态对话框中有以下选择输入:

<div class="form-group">
                            <label class="col-sm-3  control-label">Status</label>
                          <div class="col-sm-9">
                              <select class="form-control" id="txtstatus" >

                                  <option  value="1" selected="selected"> En proceso </option>
                                  <option value="2"> Solucionado </option>
                                  <option value="3"> Cancelado </option>


                              </select>
                          </div>
                        </div>

但它未被选为默认值。

屏幕截图来演示它:

enter image description here

已编辑:完整模态对话框:

              <div id="modalcust" class="modal">

                <div class="modal-dialog modal-md">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal">X</button>
                      <h4 class="modal-title">Formulario de Capacitaciones</h4>
                    </div>
                    <!--modal header-->
                    <div class="modal-body">
                      <div class="pad" id="infopanel"></div>
                      <div class="form-horizontal">

                        <div class="form-group"> 
                          <label class="col-sm-3  control-label">Número</label>
                          <div class="col-sm-9">
                              <input type="text" class="form-control" id="txtnumero" placeholder="Número de Capacitación" readonly>
                              <input type="hidden" id="crudmethod" value="N"> 
                              <input type="hidden" id="txtid" value="0">
                            </div>
                        </div>

                           <div class="form-group">
                            <label class="col-sm-3  control-label">Unidad Médica</label>
                          <div class="col-sm-9">
                              <select class="form-control" id="txtunidad" >


                              <?php
include "../config.php";
$query=mysqli_query($link,"SELECT * FROM tb_unidades") ;
$data = array();
while($r = mysqli_fetch_assoc($query)) {
    $data[] = $r;
}
$i=0;
foreach ($data as $key) {
        // add new button
    $data[$i]['button'] ;
    echo '<option value="'.$data[$i]['id_unidad'].'">'.$data[$i]['nombre_unidad'].'</option>';
    $i++;
}
$datax = array('data' => $data);
echo json_encode($datax);
?>



                              </select>
                          </div>
                        </div>

                           <div class="form-group">
                            <label class="col-sm-3  control-label">Instrumento</label>
                          <div class="col-sm-9">
                              <select class="form-control" id="txtinstrumento" name="txtinstrumento" >


                              <option value="">Selecciona primero la Unidad Médica</option>

                              </select>
                          </div>
                        </div>
                        <div class="form-group"> 
                          <label class="col-sm-3  control-label">Area</label>
                          <div class="col-sm-9">
                              <input type="text" class="form-control" id="txtarea" placeholder="Area" readonly>
                              <input type="hidden" id="crudmethod" value="N"> 
                              <input type="hidden" id="txtid" value="0">
                            </div>
                        </div>
                     <div class="form-group"> 
                          <label class="col-sm-3  control-label">Descripción</label>
                          <div class="col-sm-9">
                              <input type="text" class="form-control" id="txtdescripcion" placeholder="Descripción de la capacitación">
                            </div>
                        </div>
                          <div class="form-group"> 
                          <label class="col-sm-3  control-label">Responsable</label>
                          <div class="col-sm-9">
                              <input type="email" class="form-control" id="txtresponsable" placeholder="Responsable" required>
                            </div>
                        </div>

                        <div class="form-group"> 
                          <label class="col-sm-3  control-label">Email</label>
                          <div class="col-sm-9">
                              <input type="email" class="form-control" id="txtemail" placeholder="Email" required>
                            </div>
                        </div>

                        <div class="form-group"> 
                          <label class="col-sm-3  control-label">Celular</label>
                          <div class="col-sm-9">
                              <input type="number" class="form-control" id="txttel" placeholder="Celular">
                            </div>
                        </div>
                            <div class="form-group"> 
                          <label class="col-sm-3  control-label">Tel fijo</label>
                          <div class="col-sm-9">
                              <input type="number" class="form-control" id="txttelfijo" placeholder="Tel fijo">
                            </div>
                        </div>
                         <div class="form-group"> <!-- Date input -->
         <label class="col-sm-3  control-label">Fecha Solicitud Capacitación</label>

         <?php 
         // Change the line below to your timezone!
date_default_timezone_set('America/Mexico_City');
$date = date('d-m-Y h:i:s', time());?>
                          <div class="col-sm-9">
        <input class="form-control" id="txtfechapeticion" name="txtfechapeticiom" placeholder="yyyy-mm-dd" type="text" value="<?php echo $date?>" readonly/>
      </div>
      </div>
                               <div class="form-group"> <!-- Date input -->
         <label class="col-sm-3  control-label">Fecha Inicio</label>
                          <div class="col-sm-9">
        <input class="form-control" id="txtfechareporte" name="txtfechareporte" placeholder="dd-mm-yyyy" type="text"/>
      </div>
      </div>
          <div class="form-group"> <!-- Date input -->
         <label class="col-sm-3  control-label">Fecha Final</label>
                          <div class="col-sm-9">
        <input class="form-control" id="txtfechasolucion" name="txtfechasolucion" placeholder="dd-mm-yyyy" type="text"/>
      </div>
      </div>
                   <div class="form-group">
                            <label class="col-sm-3  control-label">Status</label>
                          <div class="col-sm-9">
                              <select class="form-control" id="txtstatus" >

                                  <option  value="1" selected="selected"> En proceso </option>
                                  <option value="2"> Solucionado </option>
                                  <option value="3"> Cancelado </option>


                              </select>
                          </div>
                        </div>
                        <div class="form-group"> 
                          <label class="col-sm-3  control-label">Comentarios</label>
                          <div class="col-sm-9">
                              <input type="text" class="form-control" id="txtcomentarios" placeholder="Comentarios">
                            </div>
                        </div>
                        <div class="form-group"> 
                          <label class="col-sm-3  control-label"></label>
                          <div class="col-sm-9">
                            <button type="submit" class="btn btn-primary "   id="btnsave"><i class="fa fa-save"></i> Guardar</button></div>
                        </div>
                      </div>
                      </div>
                      <!--modal footer-->
                    </div>
                    <!--modal-content-->
                  </div>
                  <!--modal-dialog modal-lg-->
                </div>
                <!--form-kantor-modal-->
              </div>

1 个答案:

答案 0 :(得分:0)

尝试使用<option value="1" selected>