Send combobox and checkbox data to another table

0

First of the button submit that loses the action when I put my script to configure my table. Here are some steps to take:

  • I load my table with data from another table, clients name.

  • I need to select the name of a collaborator and one or more clients through checkbox in the table and send this data to another table. In other words, the table will be composed of the employee ID linked to the Customer ID, which in this case would be the employee responsible for those clients.

  • JavaScript

    <script>
        $(function(){
    
          $('table > tbody > tr:odd').addClass('odd');
    
          $('table > tbody > tr').hover(function(){
            $(this).toggleClass('hover');
          });
    
          $('#marcar-todos').click(function(){
            $('table > tbody > tr > td > :checkbox')
              .attr('checked', $(this).is(':checked'))
              .trigger('change');
          });
    
          $('table > tbody > tr > td > :checkbox').bind('click change', function(){
            var tr = $(this).parent().parent();
            if($(this).is(':checked')) $(tr).addClass('selected');
            else $(tr).removeClass('selected');
          });
    
          $('form').submit(function(e){ e.preventDefault(); });
    
          $('#pesquisar').keydown(function(){
            var encontrou = false;
            var termo = $(this).val().toLowerCase();
            $('table > tbody > tr').each(function(){
              $(this).find('td').each(function(){
                if($(this).text().toLowerCase().indexOf(termo) > -1) encontrou = true;
              });
              if(!encontrou) $(this).hide();
              else $(this).show();
              encontrou = false;
            });
          });
    
          $("table") 
            .tablesorter({
              dateFormat: 'uk',
              headers: {
                0: {
                  sorter: false
                },
                5: {
                  sorter: false
                }
              }
            }) 
            .tablesorterPager({container: $("#pager")})
            .bind('sortEnd', function(){
              $('table > tbody > tr').removeClass('odd');
              $('table > tbody > tr:odd').addClass('odd');
            });
    
        });
        </script>
    

    HTML / PHP

    <html>
      <head>
       <meta charset="utf-8" />
    
        <link rel="stylesheet" type="text/css" href="_css/_cadastro.css"/>
        <link rel="stylesheet" type="text/css" href="_css/form.css"/>
        <link rel="icon" href="_imagens/icone.ico">
        <script language="JavaScript" src="../js/dataCad.js"></script>
        <script language="JavaScript" src="../js/formatarMascara.js"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script><scriptsrc="jquery.tablesorter.min.js"></script>
        <script src="jquery.tablesorter.pager.js"></script>
        <link rel="stylesheet" href="custom.css" media="screen" />
      </head>
      <body>
    
      <?php
            include_once("conexao2.php");
    
            $sqlProfessor="SELECT IdProf, NomeProf FROM professor" ;
    
            $resultado = mysqli_query($conn,$sqlProfessor);
    
            ?>
    
      <div id="interface">
        <header id="cabecalho">
            <hgroup>
                <h1>Clínica Escola</h1>
                <h2>Cadastro</h2>
            </hgroup>
    
             <img id="imgpos" src="../_imagens/psicologia.png"/>
            <img id="imgpos2" src="../_imagens/logo-pitagoras.png"/>
        </header>
    
        <header id="corpo">
    
    
        <form >
        <div id="formulario">
    
                 <div class="esquerda" id="">
    
    
             <label for="">Selecione um Professor</label>
             <select name="professor" >
             <option>Selecione...</option>
    
             <?php while($prod = mysqli_fetch_assoc($resultado)) { 
            echo '<option value="'.$prod['IdProf'] .'">'.$prod['NomeProf'].'</option>'."\n";
    
              } 
              ?>
    
             </select>
    
                </div>
            </div>
        </form> 
    <br>
    <br>
    <br>
    
        <form  method="post" action="testaPHP.php" >
          <p>
            <label for="pesquisar">Pesquisar</label>
            <input type="text" id="pesquisar" name="pesquisar" size="30" />
          </p>
        </form>
    
        <?php
    
            $sql="SELECT c.IdCliente,c.NomeCliente,c.IdadeCliente,c.Celular,s.NomeStatus FROM cliente c,Status s WHERE c.IdStatus=s.IdStatus" ;
    
            $result = mysqli_query($conn,$sql);
    
    
        echo"
        <table cellspacing='0'>
          <thead>
            <tr>
              <th><input type='checkbox' value='1' id='marcar-todos' name='marcar-todos' /></th>
              <th>ID</th>
              <th>Nome</th>
              <th>Idade</th>
              <th>Telefone</th>
              <th>Status</th>
              <th>Ações</th>
            </tr>
          </thead>";
    
          while($escrever=mysqli_fetch_array($result)){
              foreach($escrever AS $key => $value) { $escrever[$key] = stripslashes($value); }
    
          echo "<tbody>";
           echo" <tr>";
      echo "<td valign='top'><input type='checkbox' name='ativo[]'value={$escrever['IdCliente']}>";
            echo"<td>".$escrever['IdCliente']."</td>";
              echo"<td>".$escrever['NomeCliente']."</td>";
              echo"<td>".$escrever['IdadeCliente']."</td>";
             echo" <td>".$escrever['Celular']."</td>";
              echo"<td>".$escrever['NomeStatus']."</td>";
              echo"<td>";
               echo" <a href='#'><img src='edit.png' width='16' height='16' /></a>";
               echo" <a href='#'><img src='delete.png' width='16' height='16' /></a>";
              echo"</td>";
            echo"</tr>";
          echo"</tbody>";
          }
        echo"</table>";
    
        ?>
    
        <div id="pager" class="pager">
            <form>
                    <span>
                        Exibir <select class="pagesize">
                                <option selected="selected"  value="10">10</option>
                                <option value="20">20</option>
                                <option value="30">30</option>
                                <option  value="40">40</option>
                        </select> registros
                    </span>
    
                    <img src="first.png" class="first"/>
                <img src="prev.png" class="prev"/>
                <input type="text" class="pagedisplay"/>
                <img src="next.png" class="next"/>
                <img src="last.png" class="last"/>
            </form>
        </div>
        <br>
    <br>
    <br>
    <br>
    <br>
    <br>
        <form name="prof" method="post" action="check.php">
            <input type="submit" /> 
        </form> 
    
      </body>
    </html>
    
        
    asked by anonymous 02.06.2017 / 13:12

    0 answers