0
Now follow the function; what I need is to simply pass the value of a Javascript variable into PHP, if I make an isolated code without so many quotes and calls works, but when I mix everything gives problem, I believe it is two things
1-something related to closing tags < script > 2-start and end of quotation marks.
the problem lies in this blessed line
$table = "< script >Document.write(varTB)< /script >";
If I put the SQL string in the hand, it works well... but when I try to write it doesn’t work. what can be ?
Give me a strength there, I’m crawling in the web world. grateful
   <button name="addEnvolvido" onclick="carregaCombo('tipolocal','idocorrencia')">Adicionar</button><br/>    
 <select id="idocorrencia">
          <option value=""></option>
</select>
<?php include("conexao.php"); ?>
<script type="text/javascript">
    function carregaCombo(nomeTB, nomeCombo)
    {
         select = document.getElementById(nomeCombo);
         var varTeste = '';
         var varTB = nomeTB;
            varTeste =
            <?php
                //echo '"item 1"';
                        $tabela = "<script>document.write(varTB)</script>";
                        $varResult = '"';
                        $result = mysqli_query($con, 'SELECT id, nome FROM ' . $tabela);
                                //nomeTB ORDER BY nome');
                        while($row = mysqli_fetch_array($result))
                        {  
                           $varResult .= $row[0] . '-' . $row[1] . ';';
                        }
                        //remove o ultimo ; da variavel
                        $varResult = substr($varResult,0,-1);
                        $varResult .= '"';
                        echo $varResult;
            ?>;
                                        //agora separar o ID do nome
            for (var i = 0; i < varTeste.split(";").length ; i++)
            {
                var opt = document.createElement('option');
                opt.value = varTeste.split(";")[i];
                opt.innerHTML = varTeste.split(";")[i];
                select.appendChild(opt);
            }
    }
If anyone finds it easy, I’m sure this has been answered countless times. Damned template that makes people think that languages communicate directly.
– Maniero
tou here seeing. js runs on the client side, the PHP of the server. it is not possible to print in a PHP variable the variable js ?
– Cleverton Carneiro
Possibility of dup: http://answall.com/q/25136/101
– Maniero
Blza. Roger. Obg
– Cleverton Carneiro