0
You guys talking, Blz? I’m a beginner in php and have a table populated with while and need to use the value of a td in a select on another page returning in a modal. The structure I built works if I put the value manually in the script, but when I search directly from the table no information comes.
When I change Date: {expense: expense}, to Date: {expense: 4}, the data goes correctly to Div in Modal, otherwise only the headers appear.
The code is like this:
Index.html - TD
<td id="despesa"><?php echo $dados['cod_despesa']; ?></td>
<td id="janeiro" data-toggle="modal" data-id="1" data-target="#modal_detalhes"><?php echo $dados['janeiro']; ?></td>
Div - Modal
<div id="dados" class="modal-body modal-xs"></div>
Script
function janeiro(despesa)
        {
            var page = "analitico.php";
            $.ajax
                    ({
                        type: 'POST',
                        dataType: 'html',
                        url: page,
                        beforeSend: function () {
                            $("#dados").html("Carregando...");
                        },
                        data: {despesa: despesa},
                        success: function (msg)
                        {
                            $("#dados").html(msg);
                        }
                    });
        }
        $('#janeiro').click(function () {
            janeiro($("#despesa").val())
        });
Analytic.php
$sql_detalhe_janeiro = "select..";  $detalhe_fevereiro = mssql_query($sql_detalhe_fevereiro);
Modal table
<?php 
    while($dados = mssql_fetch_assoc($detalhe_janeiro)) {?>
    <tr>
        <td><?php echo $dados['DESCRICAO']; ?></td>
The method
.val()is for<input>. Forehead to wear$("#despesa").text().– Sergio
Speaking Sergio, blz? It worked, is bringing the data from my select but only brings the first expense of the table, so it is not
– Eduardo
What do you mean? You want to send the entire table to the analytical file?
– adventistaam
No, I will send only the cod_expense that will be used in another select in the analytic.php ( ..Where cod_expense = $cod_expense ). In the td where this information is put the id 'expense''.
– Eduardo