Error picking up a BD result and giving an Hide in a javascript option

Asked

Viewed 31 times

-2

Good evening, I’m making a mini point system where I want the system to do a search and if the result is true (in my case it returns that has 1 line) I wanted the javascript to give an Hide in the option, below I leave a little code

 <!-- Modal -->
 <?php
    include_once('conexao.php');
    $hoje = date('Y/m/d');
    $select = "select entrada from ponto where ponto_data = '$hoje'";
    $resultado = mysqli_query($conn, $select);
    $linhas = mysqli_num_rows($resultado);   
?>
<script>
function exibir_ocultar(){
    var result = "<?php echo $linhas; ?>".val();

    if(result == "1"){
        document.getElementById("entrada").style.display = "none";
     }else{
        
     }
}
</script>
<form method="post" action="mysql_ponto.php" enctype="multipart/form-data">        
    <div class="modal fade bd-example-modal-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-header" style="background-color: #0480be;">
                    <h4 class="modal-title" id="myModalLabel" style="color:white;text-align: center;">Relógio de Ponto<? echo $linhas?></h4>
                </div>
                <div class="modal-body">
                    <select id="valor" name="valor">
                        <option value="entrada" id="entrada">Entrada</option>
                        <option value="inicioa">Inicio Almoço</option>
                        <option value="fima">Fim Almoço</option>
                        <option value="fim">Final do dia</option>
                    </select>
                    <br>
                </div>
                <div class="modal-footer" style="background-color: #0480be;">
                    <button type="button" class="btn btn-default btn-md" data-dismiss="modal" onClick="JavaScript: window.history.back();">
                        Sair
                    </button>
                    <button type="submit" class="btn btn-warning btn-md" name="btnAcao" id="btnAcao" value="pes">
                         Confirmar
                    </button>
                </div>
            </div>
        </div>
    </div>
</form>
<script>
    $(document).ready(function(){
        $('#myModal').modal('show');
    });
</script>

From now on I thank you all

1 answer

-2

http://jsfiddle.net/mblase75/nh5eW/ ):

 $('#sel').data('options', $('#sel option').detach()); // data variable
     $('a').on('click', function (e) {
        e.preventDefault();
        var $sel = $('#sel').data('options'), // jQuery object
        c = 'name-of-class-to-show';
     $('#sel').empty().append( $sel.filter('.'+c) );
 });
  • Thanks but I managed to do with the above solution

Browser other questions tagged

You are not signed in. Login or sign up in order to post.