How to call input text function when clicking in the category

Asked

Viewed 84 times

0

How to create a function that by clicking on category it opens a screen with input text for an observation in the request.

If anyone can help me with that, I give two complete systems for PDV.

inserir a descrição da imagem aqui

My code is like this:

<div id="boxprodutos"><br/>
<form action="/">
<input type="text" name="obs"><br>
 <input type="submit" value="Submit">
</form>

<?php if($sit == "1"){
include "selecionacat.php";
} ?>
    <div id="comentarios2">
    <ul>
    <?php   
    $idCategoria = $_GET['id_categoria'];
    $seleciona = mysql_query("SELECT * FROM tbl_produtos WHERE id_categoria = '$idCategoria' ORDER BY nome ASC") or die(mysql_error());
    $contar = mysql_num_rows($seleciona);

    if($contar == 0){
        echo "";
    }else{      
        while($res_comentarios = mysql_fetch_array($seleciona)){        

            $cod          = $res_comentarios['cod'];
            $nome         = $res_comentarios['nome'];
            $preco      = $res_comentarios['preco'];
            $data         = $res_comentarios['data'];

            $hora        = $res_comentarios['hora'];
            $destino      = $res_comentarios['destino'];
            $obs      = $res_comentarios['obs'];

    ?>
<li><a href="cadastra.php?cod=<?php echo $cod ?>&nome=<?php echo $nome ?>&preco=<?php echo $preco ?>&qtd=1&mesa=<?php echo $numero ?>&idGarcon=<?php echo $idGarcon; ?>&destino=<?php echo $destino ?>" class="btn"><?php echo $nome; ?></a>
</li> 
    <?php 
        }
    }   
    ?>    
    </ul>    
    </div><!--// fecha comentários --> 
</div><!--// fecha box -->
<div id="box">
    <div id="comentarios">
    <table width="100%" border="0" class="inputs">
  <tr>
 <?php $n = mysql_query("SELECT * FROM config");
    $a = mysql_fetch_array($n);
 ?>
  <td align="center" style="font-size:16px;"><strong>Mesa nº: <?php echo $numero ?></strong></td>
  </tr>
  <tr>
    <td align="center" style="font-size:16px;"><?php echo $a['empresa'] ?><br/> <?php echo date("d/m/y") ?><br/><?php echo $hora = date("H:i:s"); ?></td>
    </tr>
    <tr>
    <td><hr/></td>
    </tr>
  </tr>
</table>
<script type="text/javascript">
var win = null;
function Cozinha(pagina,nome,w,h,scroll){
    LeftPosition = (screen.width) ? (screen.width-w)/3 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/3 : 0;
    settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
    win = window.open(pagina,nome,settings);
}

</script>   
    <table width="100%">
    <tr>
      <td  style="font-size:16px;"><strong>Produtos</strong></td>
      <td width="13%" align="center" style="font-size:16px;"><strong>QDT</strong></td>
      <td width="15%" align="center" style="font-size:16px;"><strong>UN</strong></td>
      <td align="center" style="font-size:16px;"><strong>TOTAL</strong></td>
      <td align="center">&nbsp;</td>
      </tr>
    <?php   

    $carrinho = mysql_query("SELECT *, SUM(qtd) AS qt,SUM(preco) AS pr FROM tbl_carrinho WHERE id_mesa='$numero' AND situacao='1' GROUP BY cod") or die(        mysql_error());
    $contar = mysql_num_rows($carrinho);

    if($contar == 0){
        echo "";
    }else{      
        while($res = mysql_fetch_array($carrinho)){     

            $id             = $res['id'];
            $cod            = $res['cod'];
            $nome           = $res['nome'];
            $preco          = $res['pr'];   
            $qtd            = $res['qt'];
            $unitario       = $res['preco'];
            $comanda        = $res['comanda'];
            $data           = $res['data'];
            $id_mesa        = $res['id_mesa'];

            $obs            = $res['obs'];

            $itens +=$qtd;
            $total += $preco;
    ?>
    <tr class="fontcomanda">
    <td width="60%" align="left">
    <a href="cozinha.php?id_mesa=<?php echo $id_mesa ?>&nome=<?php echo $nome; ?>"  title="Imprimir"
    onclick="Cozinha(this.href,'nomeJanela','350','600','yes');return false" class="fontcomanda"><?php echo $nome; ?></a>
    </td>
    <td align="center" ><?php echo $qtd; ?> </td>
    <td align="center" ><?php echo  str_replace(".",",",$unitario); ?></td>
    <td width="10%" align="right"><?php echo number_format($preco, 2, ',', '.'); ?></td>
    <td width="2%" align="right">
    <a href="inicio.php?btn=vendermesa&retira=produto&id=<?php echo $id ?>&id_mesa=<?php echo $numero ?>"><img src="imagens/icone_delete.gif" width="17" height="18" border="0" /></a>
    </td>
    </tr>
  • You can capture the event of change of select and perform the action to open the modal with the input you want.

  • I could show you in more or less code how to do it.

  • You can also place an event window.open() in each option of select passing by: table id and id of the category by the link(GET). On completion, close the window with window.close(). All with Javascript pure.

  • I tried to do more didn’t turn out as expected.

No answers

Browser other questions tagged

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