0

I'm basically getting form elements that I'm making in php. The reason is when I call the database, I want my table to contain everything. I figured I'd just simply json_encode it all. Its all showing up great. However, I am not able to use any of the form elements for some reason.

Is there anything that prevents this from functioning correctly? Without posting the litany of code, here is a brief synapse:

A website button ajax calls a php call. - The php file calls the database and creates a table with the information in the database to include the formatted input types I have. - The php file json_encodes it all. - I'm successfully returning everything to the page through the jQuery ajax call.

When I try to console.log("test") one of the radio functions, it displays nothing. Which is very wierd, because I'm using successful code that I have in other places, of which, is not generated from a json_encode through PHP.

I'll post the code, beware, I'm not that good lol.

if (isset($_POST['getWeek'])) { 
    $getLeague = mysql_real_escape_string($_POST['league']);
    $getWeek = mysql_real_escape_string($_POST['getWeek']);
    if ($_POST['getWeek'] != "Week #") { 
    //match listing for Pilot Modification
        $table = "
            <form action=''  method='post'>
<input type='hidden' name='s' value='{vb:raw session.sessionhash}' />
<input type='hidden' name='securitytoken' value='{vb:raw bbuserinfo.securitytoken}' />
            <table class='tg' style='undefined;table-layout: auto; width: 100%; margin: auto;'>
                <colgroup>
                <col style='width: 21px'>
                <col style='width: 157px'>
                <col style='width: 21px'>               
                <col style='width: 157px'>
                <col style='width: 21px'>
                <col style='width: 157px'>
                <col style='width: 21px'>
                <col style='width: 151px'>
                <col style='width: 20px'>
                <col style='width: 157px'>
                <col style='width: 21px'>
                <col style='width: 157px'>
                <col style='width: 21px'>
                <col style='width: 157px'>
                <col style='width: 21px'>
                <col style='width: 159px'>
                </colgroup>
                <tr>
                <td class='tg-a0td'></td>
                <td class='tg-1rn1'>MatchNum</td>
                <td class='tg-a0td'></td>
                <td class='tg-1rn1'>Player</td>
                <td class='tg-a0td'></td>
                <td class='tg-1rn1'>Mech</td>
                <td class='tg-a0td'></td>
                <td class='tg-1rn1'>Status</td>
                <td class='tg-031e'></td>
                <td class='tg-1rn1'>Match Score<br></td>
                <td class='tg-a0td'></td>
                <td class='tg-1rn1'>Kills</td>
                <td class='tg-a0td'></td>
                <td class='tg-1rn1'>Assists<br></td>
                <td class='tg-a0td'></td>
                <td class='tg-1rn1'>Damage</td>
                </tr>";
        $query = mysql_query("SELECT * FROM vb_mwo_scoreboard WHERE league='$getLeague' AND week='$getWeek' ORDER BY week, league", $con) or die("Query failed: <font color='red' size='2>getWeek</font>" . mysql_error());
        while($r = mysql_fetch_array($query)) {
            $mech = htmlentities($r['mech'], ENT_QUOTES);//html special chars
            if ($r['status'] == 0) { $status = "Alive"; } 
            if ($r['status'] == 1) { $status = "Dead"; } 
            $score = $r['score'];
            $kills = $r['kills']; 
            $assists = $r['assists']; 
            $damage = $r['damage']; 
            $player = $r['player']; 
            $matchNum = $r['matchNum'];
            $radio = "<span class='dataSelected'><font size='1'><input type='button' name='$player' id='modify' value='Modify'></font></span>";
            //$radio = htmlentities($radio, ENT_QUOTES);
            $table .= "

            <tr>
                <td class='tg-031e'>$radio</td>
                <td class='tg-031e'><span class='dataSelected'><span id='mMatchNum'>$matchNum</span></span></td>
                <td class='tg-031e'></td>               
                <td class='tg-031e'><span class='dataSelected'><span id='mPlayer'>$player</span></span></td>
                <td class='tg-031e'></td>
                <td class='tg-031e'><span class='dataSelected'><span id='mMech'>$mech</span></span></td>
                <td class='tg-031e'></td>
                <td class='tg-031e'><span class='dataSelected'><span id='mStatus'>$status</span></span></td>
                <td class='tg-031e'></td>
                <td class='tg-031e'><span class='dataSelected'><span id='mScore'>$score</span></span></td>
                <td class='tg-031e'></td>
                <td class='tg-031e'><span class='dataSelected'><span id='mKills'>$kills</span></span></td>
                <td class='tg-031e'></td>
                <td class='tg-031e'><span class='dataSelected'><span id='mAssists'>$assists</span></span></td>
                <td class='tg-031e'></td>
                <td class='tg-031e'><span class='dataSelected'><span id='mDamage'>$damage</span></span></td>
            </tr></form>";
            $json = array(
            'match' => $matchNum,
            'table' => $table,
            'radio' => $radio,
            'mech' => $mech,
            'status' => $status,
            'score' => $score,
            'kills' =>$kills,
            'assists' => $assists,
            'damage' => $damage,
            'player' => $player
        );
        }
        $table .= "</table>";
        echo json_encode($json);
    }
}

Now all my code to display the data is functioning correctly at this point. Everything is working as I intended. At the next point. I'm trying to simply test the button to see if I get a console.log("test"). Its not happening.

$("#modify").click(function () {
console.log("clicked");
});

Its acting like there is no form. From what I can tell. I also had to do the entire table in PHP because it was acting like it was split if i tried to just do the and have the rest of the table in the main page. It seems like things are inhibited somehow. Is there a limitation with jQuery that I dont know?

Medi0cr3
  • 15
  • 4

0 Answers0