onclik events on table do not work

Asked

Viewed 48 times

-1

I have a table in a php file with some events onclick that I need to call after the page is loaded. But when I try to click one of the values or button input submit no reaction. follow the code. I appreciate if anyone can help.

<div style='overflow-x: auto; overflow-y: scroll; width: 1200px; height: 400px;'> 

    <form method="POST" id="formIdJog">

    <input type="hidden" id="id_jogo" name="quejogo">

    <table id="tabela_escolha_jogos" class="lista-jogos">
    <tr>
    <th>Time A</th>
    <th>Time B</th>
    <th>Data-Hora</th>
    <th>Campeonatos</th>
    <th>Casa</th>
    <th>Empate</th>
    <th>Fora</th>
    <th>Mais</th>
    </tr>
    <tbody>

    <?php
    function formDt($dt){
        //21/12/2016 17:30
        $ano = substr($dt, 0, 4);
        $mes = substr($dt,5, 2);
        $dia = substr($dt,8, 2);
        $hora = substr($dt,11, 2);
        $min = substr($dt,14, 2);
        return $dia . '/' . $mes . '/' . $ano . ' - ' . $hora . ':' . $min;
        //return new Date(ano, mes - 1, dia, hora, min, 0);
    }

    $decodifi = file_get_contents("http://pansudopoker.com/futebolapi/api/CampJogos");
     $dados = json_decode($decodifi, true);

        foreach($campeonatos as $campeonato){ //ta no select

            echo "<tr style='background-color: #008000;'> 
            <td>
            <span name='camp'>".$campeonato['CAMP_NOME']."</span>
            </td>
            </tr>";

            foreach($dados as $dado){
                $dia = substr($dado['dt_hr_ini'], 8, 2); 
                $data = formDt($dado['dt_hr_ini']);
                if($dado["esporte"] == "Futebol" && $dado['Odds'] != null && $dia >= date('d') && 
                $campeonato['CAMP_NOME'] == $dado['camp_nome']):
                $cod = $dado['camp_jog_id'];?>

                <tr id='id_linha' onclick='escolheJogos(this), calcPremio()' >
                <td>
                <span name='id_timea'><?php echo $dado['casa_time']?></span>
                </td>
                <td>
                <span name='id_timeb'><?php echo $dado['visit_time'] ?></span>
                </td>
                <td>
                <span name='id_data'><?php echo $data ?></span>
                </td>
                <td>
                <span><?php echo $dado['camp_nome'] ?></span> 
                </td>
                <td>
                <span name='id_casa' onclick=escolhaCotacao(0)><?php echo $dado['Odds'][0]['taxa'] ?> </span>
                </td>
                <td>
                <span name='id_empate' onclick=escolhaCotacao(1)><?php echo $dado['Odds'][1]['taxa'] ?></span>
                </td>
                <td>
                <a href="javascript:escolhaCotacao(2)"><?php echo $dado['Odds'][2]['taxa'] ?> </a>
                </td>
                <td>
                <button id='id_sub' type='submit' onclick=insere(this)> <?php echo $cod ?> </button>  
                </td>
                </tr>

                <?php endif;
           }
          // return;
        }
    ?> 
    </tbody>
    </table>
    </form>
    </div>

inserir a descrição da imagem aqui

  • Where is your function insert() ? Post it tbm.

  • Function inserts(ref) { var code = $(ref). val();

  • sorry and Function inserts(ref) { var code = $(ref). text();}

1 answer

0

Your Ubmit button’s onclick is quote-free.

<td>
  <button id='id_sub' type='submit' onclick=insere(this)> <?php echo $cod ?> </button>  
</td>

Should stay that way

<td>
  <button id='id_sub' type='submit' onclick='insere(this)'> <?php echo $cod ?> </button>  
</td>
  • friend still doesn’t work. I noticed that the last row of table visible on the monitor works, the other upper not.

Browser other questions tagged

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